Re: [PATCH] drivers: mcb: use symbol namespaces

2019-10-16 Thread Michael Moese



On 16.10.19 12:01, Johannes Thumshirn wrote:
> Now that we have symbol namespaces, use them in MCB to not pollute the
> default namespace with MCB internals.
> 
> Signed-off-by: Johannes Thumshirn 

Reviewed-by: Michael Moese 

> ---
>  drivers/gpio/gpio-menz127.c|  1 +
>  drivers/iio/adc/men_z188_adc.c |  1 +
>  drivers/mcb/mcb-core.c | 28 ++--
>  drivers/mcb/mcb-lpc.c  |  1 +
>  drivers/mcb/mcb-parse.c|  2 +-
>  drivers/mcb/mcb-pci.c  |  1 +
>  drivers/tty/serial/8250/8250_men_mcb.c |  1 +
>  drivers/tty/serial/men_z135_uart.c |  1 +
>  drivers/watchdog/menz69_wdt.c  |  1 +
>  9 files changed, 22 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-menz127.c b/drivers/gpio/gpio-menz127.c
> index 70fdb42a8e88..1e21c661d79d 100644
> --- a/drivers/gpio/gpio-menz127.c
> +++ b/drivers/gpio/gpio-menz127.c
> @@ -211,3 +211,4 @@ MODULE_AUTHOR("Andreas Werner ");
>  MODULE_DESCRIPTION("MEN 16z127 GPIO Controller");
>  MODULE_LICENSE("GPL v2");
>  MODULE_ALIAS("mcb:16z127");
> +MODULE_IMPORT_NS(MCB);
> diff --git a/drivers/iio/adc/men_z188_adc.c b/drivers/iio/adc/men_z188_adc.c
> index 3b2fbb7ce431..196c8226381e 100644
> --- a/drivers/iio/adc/men_z188_adc.c
> +++ b/drivers/iio/adc/men_z188_adc.c
> @@ -167,3 +167,4 @@ MODULE_AUTHOR("Johannes Thumshirn 
> ");
>  MODULE_LICENSE("GPL");
>  MODULE_DESCRIPTION("IIO ADC driver for MEN 16z188 ADC Core");
>  MODULE_ALIAS("mcb:16z188");
> +MODULE_IMPORT_NS(MCB);
> diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
> index b72e82efaee5..38fbb3b59873 100644
> --- a/drivers/mcb/mcb-core.c
> +++ b/drivers/mcb/mcb-core.c
> @@ -191,7 +191,7 @@ int __mcb_register_driver(struct mcb_driver *drv, struct 
> module *owner,
>  
>   return driver_register(>driver);
>  }
> -EXPORT_SYMBOL_GPL(__mcb_register_driver);
> +EXPORT_SYMBOL_NS_GPL(__mcb_register_driver, MCB);
>  
>  /**
>   * mcb_unregister_driver() - Unregister a @mcb_driver from the system
> @@ -203,7 +203,7 @@ void mcb_unregister_driver(struct mcb_driver *drv)
>  {
>   driver_unregister(>driver);
>  }
> -EXPORT_SYMBOL_GPL(mcb_unregister_driver);
> +EXPORT_SYMBOL_NS_GPL(mcb_unregister_driver, MCB);
>  
>  static void mcb_release_dev(struct device *dev)
>  {
> @@ -249,7 +249,7 @@ int mcb_device_register(struct mcb_bus *bus, struct 
> mcb_device *dev)
>  
>   return ret;
>  }
> -EXPORT_SYMBOL_GPL(mcb_device_register);
> +EXPORT_SYMBOL_NS_GPL(mcb_device_register, MCB);
>  
>  static void mcb_free_bus(struct device *dev)
>  {
> @@ -301,7 +301,7 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier)
>   kfree(bus);
>   return ERR_PTR(rc);
>  }
> -EXPORT_SYMBOL_GPL(mcb_alloc_bus);
> +EXPORT_SYMBOL_NS_GPL(mcb_alloc_bus, MCB);
>  
>  static int __mcb_devices_unregister(struct device *dev, void *data)
>  {
> @@ -323,7 +323,7 @@ void mcb_release_bus(struct mcb_bus *bus)
>  {
>   mcb_devices_unregister(bus);
>  }
> -EXPORT_SYMBOL_GPL(mcb_release_bus);
> +EXPORT_SYMBOL_NS_GPL(mcb_release_bus, MCB);
>  
>  /**
>   * mcb_bus_put() - Increment refcnt
> @@ -338,7 +338,7 @@ struct mcb_bus *mcb_bus_get(struct mcb_bus *bus)
>  
>   return bus;
>  }
> -EXPORT_SYMBOL_GPL(mcb_bus_get);
> +EXPORT_SYMBOL_NS_GPL(mcb_bus_get, MCB);
>  
>  /**
>   * mcb_bus_put() - Decrement refcnt
> @@ -351,7 +351,7 @@ void mcb_bus_put(struct mcb_bus *bus)
>   if (bus)
>   put_device(>dev);
>  }
> -EXPORT_SYMBOL_GPL(mcb_bus_put);
> +EXPORT_SYMBOL_NS_GPL(mcb_bus_put, MCB);
>  
>  /**
>   * mcb_alloc_dev() - Allocate a device
> @@ -371,7 +371,7 @@ struct mcb_device *mcb_alloc_dev(struct mcb_bus *bus)
>  
>   return dev;
>  }
> -EXPORT_SYMBOL_GPL(mcb_alloc_dev);
> +EXPORT_SYMBOL_NS_GPL(mcb_alloc_dev, MCB);
>  
>  /**
>   * mcb_free_dev() - Free @mcb_device
> @@ -383,7 +383,7 @@ void mcb_free_dev(struct mcb_device *dev)
>  {
>   kfree(dev);
>  }
> -EXPORT_SYMBOL_GPL(mcb_free_dev);
> +EXPORT_SYMBOL_NS_GPL(mcb_free_dev, MCB);
>  
>  static int __mcb_bus_add_devices(struct device *dev, void *data)
>  {
> @@ -412,7 +412,7 @@ void mcb_bus_add_devices(const struct mcb_bus *bus)
>  {
>   bus_for_each_dev(_bus_type, NULL, NULL, __mcb_bus_add_devices);
>  }
> -EXPORT_SYMBOL_GPL(mcb_bus_add_devices);
> +EXPORT_SYMBOL_NS_GPL(mcb_bus_add_devices, MCB);
>  
>  /**
>   * mcb_get_resource() - get a resource for a mcb device
> @@ -428,7 +428,7 @@ struct resource *mcb_get_resource(struct mcb_device *dev, 

Re: [PATCH] 8250-men-mcb: fix error checking when get_num_ports returns -ENODEV

2019-10-14 Thread Michael Moese




On 14.10.19 00:00, Colin King wrote:

From: Colin Ian King 

The current checking for failure on the number of ports fails when
-ENODEV is returned from the call to get_num_ports. Fix this by making
num_ports and loop counter i signed rather than unsigned ints. Also
add check for num_ports being less than zero to check for -ve error
returns.

Addresses-Coverity: ("Unsigned compared against 0")
Fixes: e2fea54e4592 ("8250-men-mcb: add support for 16z025 and 16z057")
Signed-off-by: Colin Ian King 


This looks more than reasonable to me, thanks.

Reviewed-by: Michael Moese 


---
  drivers/tty/serial/8250/8250_men_mcb.c | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_men_mcb.c 
b/drivers/tty/serial/8250/8250_men_mcb.c
index 02c5aff58a74..8df89e9cd254 100644
--- a/drivers/tty/serial/8250/8250_men_mcb.c
+++ b/drivers/tty/serial/8250/8250_men_mcb.c
@@ -72,8 +72,8 @@ static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
  {
struct serial_8250_men_mcb_data *data;
struct resource *mem;
-   unsigned int num_ports;
-   unsigned int i;
+   int num_ports;
+   int i;
void __iomem *membase;
  
  	mem = mcb_get_resource(mdev, IORESOURCE_MEM);

@@ -88,7 +88,7 @@ static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
dev_dbg(>dev, "found a 16z%03u with %u ports\n",
mdev->id, num_ports);
  
-	if (num_ports == 0 || num_ports > 4) {

+   if (num_ports <= 0 || num_ports > 4) {
dev_err(>dev, "unexpected number of ports: %u\n",
num_ports);
return -ENODEV;
@@ -133,7 +133,7 @@ static int serial_8250_men_mcb_probe(struct mcb_device 
*mdev,
  
  static void serial_8250_men_mcb_remove(struct mcb_device *mdev)

  {
-   unsigned int num_ports, i;
+   int num_ports, i;
struct serial_8250_men_mcb_data *data = mcb_get_drvdata(mdev);
  
  	if (!data)




--
Michael Moese 
QA Engineer
PGP Fingerprint: 4CCE 3896 F873 2CA5 2382  3C6F 6021 375C 8635 7E74

SUSE Software Solutions Germany GmbH
Maxfeldstr. 5
90409 Nürnberg
Germany

(HRB 247165, AG München)
Geschäftsführer: Felix Imendörffer





Re: [PATCH v2] watchdog: add driver for the MEN 16z069 IP-Core

2018-07-17 Thread Michael Moese
On Mon, Jul 16, 2018 at 09:25:10AM +0200, Johannes Thumshirn wrote:
> Add a driver for the MEN 16z069 Watchdog and Reset Controller IP-Core.
> 
> Signed-off-by: Johannes Thumshirn 

Reviewed-by: Michael Moese 

> 
> ---
> Changes to v1:
> * Sorted includes alphabetically
> * Indented defines with tabs
> * Removed unnecessary timeout validation
> * Removed unnecessary masking of values
> * Fixed error return in .probe
> * Directly accessed drv->wdt
> * Removed leftover timeout resetting
> ---
>  MAINTAINERS   |   6 ++
>  drivers/watchdog/Kconfig  |  10 +++
>  drivers/watchdog/Makefile |   1 +
>  drivers/watchdog/menz69_wdt.c | 170 
> ++
>  4 files changed, 187 insertions(+)
>  create mode 100644 drivers/watchdog/menz69_wdt.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 07d1576fc766..67a76f740294 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -9298,6 +9298,12 @@ F: drivers/leds/leds-menf21bmc.c
>  F:   drivers/hwmon/menf21bmc_hwmon.c
>  F:   Documentation/hwmon/menf21bmc
>  
> +MEN Z069 WATCHDOG DRIVER
> +M:   Johannes Thumshirn 
> +L:   linux-watch...@vger.kernel.org
> +S:   Maintained
> +F:   drivers/watchdog/menz069_wdt.c
> +
>  MESON AO CEC DRIVER FOR AMLOGIC SOCS
>  M:   Neil Armstrong 
>  L:   linux-me...@lists.freedesktop.org
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index 9af07fd92763..df55d65bbb1c 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -161,6 +161,16 @@ config MENF21BMC_WATCHDOG
> This driver can also be built as a module. If so the module
> will be called menf21bmc_wdt.
>  
> +config MENZ069_WATCHDOG
> + tristate "MEN 16Z069 Watchdog"
> + depends on MCB || COMPILE_TEST
> + select WATCHDOG_CORE
> + help
> +   Say Y here to include support for the MEN 16Z069 Watchdog.
> +
> +   This driver can also be built as a module. If so the module
> +   will be called menz069_wdt.
> +
>  config TANGOX_WATCHDOG
>   tristate "Sigma Designs SMP86xx/SMP87xx watchdog"
>   select WATCHDOG_CORE
> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> index 1d3c6b094fe5..bf92e7bf9ce0 100644
> --- a/drivers/watchdog/Makefile
> +++ b/drivers/watchdog/Makefile
> @@ -215,4 +215,5 @@ obj-$(CONFIG_MAX77620_WATCHDOG) += max77620_wdt.o
>  obj-$(CONFIG_ZIIRAVE_WATCHDOG) += ziirave_wdt.o
>  obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
>  obj-$(CONFIG_MENF21BMC_WATCHDOG) += menf21bmc_wdt.o
> +obj-$(CONFIG_MENZ069_WATCHDOG) += menz69_wdt.o
>  obj-$(CONFIG_RAVE_SP_WATCHDOG) += rave-sp-wdt.o
> diff --git a/drivers/watchdog/menz69_wdt.c b/drivers/watchdog/menz69_wdt.c
> new file mode 100644
> index ..ed18238c5407
> --- /dev/null
> +++ b/drivers/watchdog/menz69_wdt.c
> @@ -0,0 +1,170 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Watchdog driver for the MEN z069 IP-Core
> + *
> + * Copyright (C) 2018 Johannes Thumshirn 
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +struct men_z069_drv {
> + struct watchdog_device wdt;
> + void __iomem *base;
> + struct resource *mem;
> +};
> +
> +#define MEN_Z069_WTR 0x10
> +#define MEN_Z069_WTR_WDENBIT(15)
> +#define MEN_Z069_WTR_WDET_MASK   0x7fff
> +#define MEN_Z069_WVR 0x14
> +
> +#define MEN_Z069_TIMER_FREQ  500 /* 500 Hz */
> +#define MEN_Z069_WDT_COUNTER_MIN 1
> +#define MEN_Z069_WDT_COUNTER_MAX 0x7fff
> +#define MEN_Z069_DEFAULT_TIMEOUT 30
> +
> +static bool nowayout = WATCHDOG_NOWAYOUT;
> +module_param(nowayout, bool, 0);
> +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started 
> (default="
> + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
> +
> +static int men_z069_wdt_start(struct watchdog_device *wdt)
> +{
> + struct men_z069_drv *drv = watchdog_get_drvdata(wdt);
> + u16 val;
> +
> + val = readw(drv->base + MEN_Z069_WTR);
> + val |= MEN_Z069_WTR_WDEN;
> + writew(val, drv->base + MEN_Z069_WTR);
> +
> + return 0;
> +}
> +
> +static int men_z069_wdt_stop(struct watchdog_device *wdt)
> +{
> + struct men_z069_drv *drv = watchdog_get_drvdata(wdt);
> + u16 val;
> +
> + val = readw(drv->base + MEN_Z069_WTR);
> + val &= ~MEN_Z069_WTR_WDEN;
> + writew(val, drv->base + MEN_Z069_WTR);
> +
> + return 0;
> +}
> +
> +static int men_z069_wdt_ping(struct watchdog_device *wdt)
> +{
> + struct men_z069_drv *drv = watch

Re: [PATCH v2] watchdog: add driver for the MEN 16z069 IP-Core

2018-07-17 Thread Michael Moese
On Mon, Jul 16, 2018 at 09:25:10AM +0200, Johannes Thumshirn wrote:
> Add a driver for the MEN 16z069 Watchdog and Reset Controller IP-Core.
> 
> Signed-off-by: Johannes Thumshirn 

Reviewed-by: Michael Moese 

> 
> ---
> Changes to v1:
> * Sorted includes alphabetically
> * Indented defines with tabs
> * Removed unnecessary timeout validation
> * Removed unnecessary masking of values
> * Fixed error return in .probe
> * Directly accessed drv->wdt
> * Removed leftover timeout resetting
> ---
>  MAINTAINERS   |   6 ++
>  drivers/watchdog/Kconfig  |  10 +++
>  drivers/watchdog/Makefile |   1 +
>  drivers/watchdog/menz69_wdt.c | 170 
> ++
>  4 files changed, 187 insertions(+)
>  create mode 100644 drivers/watchdog/menz69_wdt.c
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 07d1576fc766..67a76f740294 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -9298,6 +9298,12 @@ F: drivers/leds/leds-menf21bmc.c
>  F:   drivers/hwmon/menf21bmc_hwmon.c
>  F:   Documentation/hwmon/menf21bmc
>  
> +MEN Z069 WATCHDOG DRIVER
> +M:   Johannes Thumshirn 
> +L:   linux-watch...@vger.kernel.org
> +S:   Maintained
> +F:   drivers/watchdog/menz069_wdt.c
> +
>  MESON AO CEC DRIVER FOR AMLOGIC SOCS
>  M:   Neil Armstrong 
>  L:   linux-me...@lists.freedesktop.org
> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> index 9af07fd92763..df55d65bbb1c 100644
> --- a/drivers/watchdog/Kconfig
> +++ b/drivers/watchdog/Kconfig
> @@ -161,6 +161,16 @@ config MENF21BMC_WATCHDOG
> This driver can also be built as a module. If so the module
> will be called menf21bmc_wdt.
>  
> +config MENZ069_WATCHDOG
> + tristate "MEN 16Z069 Watchdog"
> + depends on MCB || COMPILE_TEST
> + select WATCHDOG_CORE
> + help
> +   Say Y here to include support for the MEN 16Z069 Watchdog.
> +
> +   This driver can also be built as a module. If so the module
> +   will be called menz069_wdt.
> +
>  config TANGOX_WATCHDOG
>   tristate "Sigma Designs SMP86xx/SMP87xx watchdog"
>   select WATCHDOG_CORE
> diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> index 1d3c6b094fe5..bf92e7bf9ce0 100644
> --- a/drivers/watchdog/Makefile
> +++ b/drivers/watchdog/Makefile
> @@ -215,4 +215,5 @@ obj-$(CONFIG_MAX77620_WATCHDOG) += max77620_wdt.o
>  obj-$(CONFIG_ZIIRAVE_WATCHDOG) += ziirave_wdt.o
>  obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
>  obj-$(CONFIG_MENF21BMC_WATCHDOG) += menf21bmc_wdt.o
> +obj-$(CONFIG_MENZ069_WATCHDOG) += menz69_wdt.o
>  obj-$(CONFIG_RAVE_SP_WATCHDOG) += rave-sp-wdt.o
> diff --git a/drivers/watchdog/menz69_wdt.c b/drivers/watchdog/menz69_wdt.c
> new file mode 100644
> index ..ed18238c5407
> --- /dev/null
> +++ b/drivers/watchdog/menz69_wdt.c
> @@ -0,0 +1,170 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Watchdog driver for the MEN z069 IP-Core
> + *
> + * Copyright (C) 2018 Johannes Thumshirn 
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +struct men_z069_drv {
> + struct watchdog_device wdt;
> + void __iomem *base;
> + struct resource *mem;
> +};
> +
> +#define MEN_Z069_WTR 0x10
> +#define MEN_Z069_WTR_WDENBIT(15)
> +#define MEN_Z069_WTR_WDET_MASK   0x7fff
> +#define MEN_Z069_WVR 0x14
> +
> +#define MEN_Z069_TIMER_FREQ  500 /* 500 Hz */
> +#define MEN_Z069_WDT_COUNTER_MIN 1
> +#define MEN_Z069_WDT_COUNTER_MAX 0x7fff
> +#define MEN_Z069_DEFAULT_TIMEOUT 30
> +
> +static bool nowayout = WATCHDOG_NOWAYOUT;
> +module_param(nowayout, bool, 0);
> +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started 
> (default="
> + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
> +
> +static int men_z069_wdt_start(struct watchdog_device *wdt)
> +{
> + struct men_z069_drv *drv = watchdog_get_drvdata(wdt);
> + u16 val;
> +
> + val = readw(drv->base + MEN_Z069_WTR);
> + val |= MEN_Z069_WTR_WDEN;
> + writew(val, drv->base + MEN_Z069_WTR);
> +
> + return 0;
> +}
> +
> +static int men_z069_wdt_stop(struct watchdog_device *wdt)
> +{
> + struct men_z069_drv *drv = watchdog_get_drvdata(wdt);
> + u16 val;
> +
> + val = readw(drv->base + MEN_Z069_WTR);
> + val &= ~MEN_Z069_WTR_WDEN;
> + writew(val, drv->base + MEN_Z069_WTR);
> +
> + return 0;
> +}
> +
> +static int men_z069_wdt_ping(struct watchdog_device *wdt)
> +{
> + struct men_z069_drv *drv = watch

Re: LTP CVE cve-2017-17053 test failed on x86_64 device

2018-06-20 Thread Michael Moese
Hi,

On Wed, Jun 20, 2018 at 12:14:22PM +0530, Naresh Kamboju wrote:
> Test FAIL case output,
> tst_test.c:1015: INFO: Timeout per run is 0h 15m 00s
> tst_taint.c:88: BROK: Kernel is already tainted: 512
The kernel is already tainted. In this case, the test refuses to run,
because it could not tell if the test is pass or fail.

Could you please check if you could run the test directly after a
reboot?

Regards,
Michael
-- 
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 
(AG Nürnberg)


Re: LTP CVE cve-2017-17053 test failed on x86_64 device

2018-06-20 Thread Michael Moese
Hi,

On Wed, Jun 20, 2018 at 12:14:22PM +0530, Naresh Kamboju wrote:
> Test FAIL case output,
> tst_test.c:1015: INFO: Timeout per run is 0h 15m 00s
> tst_taint.c:88: BROK: Kernel is already tainted: 512
The kernel is already tainted. In this case, the test refuses to run,
because it could not tell if the test is pass or fail.

Could you please check if you could run the test directly after a
reboot?

Regards,
Michael
-- 
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 
(AG Nürnberg)


[PATCH v3] 8250-men-mcb: add support for 16z025 and 16z057

2018-03-05 Thread Michael Moese
Add support for two MEN UARTs (16z025 and 16z057) to the
8250_men_mcb driver.
The 16z025 consists of up to four ports, the 16z057 has
exactly four ports. Apart from that, all of them share the
Port settings.

Signed-off-by: Michael Moese <mmo...@suse.de>
Reported-by: Ben Turner <ben.tur...@21net.com>
Tested-by: Ben Turner <ben.tur...@21net.com>

---
Sorry for the resend, I messed up the previoius patch..

Changes to v2:
Added include of linux/io.h due to finding of kbuild robot.

Changes to v1:
Deduplicated the two switch() blocks into a function returning
the number of ports.
Minor style corrections.
---
 drivers/tty/serial/8250/8250_men_mcb.c | 125 -
 drivers/tty/serial/8250/Kconfig|   5 +-
 2 files changed, 94 insertions(+), 36 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_men_mcb.c 
b/drivers/tty/serial/8250/8250_men_mcb.c
index 308977807994..127017cc41d9 100644
--- a/drivers/tty/serial/8250/8250_men_mcb.c
+++ b/drivers/tty/serial/8250/8250_men_mcb.c
@@ -1,12 +1,19 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
+#define MEN_UART_ID_Z025 0x19
+#define MEN_UART_ID_Z057 0x39
+#define MEN_UART_ID_Z125 0x7d
+
+#define MEN_UART_MEM_SIZE 0x10
+
 struct serial_8250_men_mcb_data {
struct uart_8250_port uart;
int line;
@@ -18,7 +25,7 @@ struct serial_8250_men_mcb_data {
  * parameter in order to really set the correct baudrate, and
  * do so if possible without user interaction
  */
-static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
+static u32 men_lookup_uartclk(struct mcb_device *mdev)
 {
/* use default value if board is not available below */
u32 clkval = 1041666;
@@ -28,10 +35,12 @@ static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
mdev->bus->name);
if  (strncmp(mdev->bus->name, "F075", 4) == 0)
clkval = 1041666;
-   else if  (strncmp(mdev->bus->name, "F216", 4) == 0)
+   else if (strncmp(mdev->bus->name, "F216", 4) == 0)
clkval = 1843200;
else if (strncmp(mdev->bus->name, "G215", 4) == 0)
clkval = 1843200;
+   else if (strncmp(mdev->bus->name, "F210", 4) == 0)
+   clkval = 115200;
else
dev_info(>dev,
 "board not detected, using default uartclk\n");
@@ -41,62 +50,108 @@ static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
return clkval;
 }
 
+static unsigned int get_num_ports(struct mcb_device *mdev,
+ void __iomem *membase)
+{
+   switch (mdev->id) {
+   case MEN_UART_ID_Z125:
+   return 1U;
+   case MEN_UART_ID_Z025:
+   return readb(membase) >> 4;
+   case MEN_UART_ID_Z057:
+   return 4U;
+   default:
+   dev_err(>dev, "no supported device!\n");
+   return -ENODEV;
+   }
+}
+
 static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
 const struct mcb_device_id *id)
 {
struct serial_8250_men_mcb_data *data;
struct resource *mem;
-
-   data = devm_kzalloc(>dev,
-   sizeof(struct serial_8250_men_mcb_data),
-   GFP_KERNEL);
-   if (!data)
-   return -ENOMEM;
-
-   mcb_set_drvdata(mdev, data);
-   data->uart.port.dev = mdev->dma_dev;
-   spin_lock_init(>uart.port.lock);
-
-   data->uart.port.type = PORT_16550;
-   data->uart.port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
-   data->uart.port.iotype = UPIO_MEM;
-   data->uart.port.uartclk = men_z125_lookup_uartclk(mdev);
-   data->uart.port.regshift = 0;
-   data->uart.port.fifosize = 60;
+   unsigned int num_ports;
+   unsigned int i;
+   void __iomem *membase;
 
mem = mcb_get_resource(mdev, IORESOURCE_MEM);
if (mem == NULL)
return -ENXIO;
+   membase = devm_ioremap_resource(>dev, mem);
+   if (IS_ERR(membase))
+   return PTR_ERR_OR_ZERO(membase);
 
-   data->uart.port.irq = mcb_get_irq(mdev);
+   num_ports = get_num_ports(mdev, membase);
 
-   data->uart.port.membase = devm_ioremap_resource(>dev, mem);
-   if (IS_ERR(data->uart.port.membase))
-   return PTR_ERR_OR_ZERO(data->uart.port.membase);
+   dev_dbg(>dev, "found a 16z%03u with %u ports\n",
+   mdev->id, num_ports);
 
-   data->uart.port.mapbase = (unsigned long) mem->start;
-   data->uart.port.iobase = data->uart.port.mapbase;
+   if (num_ports == 0 || num_ports > 4) {
+   dev_err(>dev, "unexpected number of ports: %u\n",
+  

[PATCH v3] 8250-men-mcb: add support for 16z025 and 16z057

2018-03-05 Thread Michael Moese
Add support for two MEN UARTs (16z025 and 16z057) to the
8250_men_mcb driver.
The 16z025 consists of up to four ports, the 16z057 has
exactly four ports. Apart from that, all of them share the
Port settings.

Signed-off-by: Michael Moese 
Reported-by: Ben Turner 
Tested-by: Ben Turner 

---
Sorry for the resend, I messed up the previoius patch..

Changes to v2:
Added include of linux/io.h due to finding of kbuild robot.

Changes to v1:
Deduplicated the two switch() blocks into a function returning
the number of ports.
Minor style corrections.
---
 drivers/tty/serial/8250/8250_men_mcb.c | 125 -
 drivers/tty/serial/8250/Kconfig|   5 +-
 2 files changed, 94 insertions(+), 36 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_men_mcb.c 
b/drivers/tty/serial/8250/8250_men_mcb.c
index 308977807994..127017cc41d9 100644
--- a/drivers/tty/serial/8250/8250_men_mcb.c
+++ b/drivers/tty/serial/8250/8250_men_mcb.c
@@ -1,12 +1,19 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
+#define MEN_UART_ID_Z025 0x19
+#define MEN_UART_ID_Z057 0x39
+#define MEN_UART_ID_Z125 0x7d
+
+#define MEN_UART_MEM_SIZE 0x10
+
 struct serial_8250_men_mcb_data {
struct uart_8250_port uart;
int line;
@@ -18,7 +25,7 @@ struct serial_8250_men_mcb_data {
  * parameter in order to really set the correct baudrate, and
  * do so if possible without user interaction
  */
-static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
+static u32 men_lookup_uartclk(struct mcb_device *mdev)
 {
/* use default value if board is not available below */
u32 clkval = 1041666;
@@ -28,10 +35,12 @@ static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
mdev->bus->name);
if  (strncmp(mdev->bus->name, "F075", 4) == 0)
clkval = 1041666;
-   else if  (strncmp(mdev->bus->name, "F216", 4) == 0)
+   else if (strncmp(mdev->bus->name, "F216", 4) == 0)
clkval = 1843200;
else if (strncmp(mdev->bus->name, "G215", 4) == 0)
clkval = 1843200;
+   else if (strncmp(mdev->bus->name, "F210", 4) == 0)
+   clkval = 115200;
else
dev_info(>dev,
 "board not detected, using default uartclk\n");
@@ -41,62 +50,108 @@ static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
return clkval;
 }
 
+static unsigned int get_num_ports(struct mcb_device *mdev,
+ void __iomem *membase)
+{
+   switch (mdev->id) {
+   case MEN_UART_ID_Z125:
+   return 1U;
+   case MEN_UART_ID_Z025:
+   return readb(membase) >> 4;
+   case MEN_UART_ID_Z057:
+   return 4U;
+   default:
+   dev_err(>dev, "no supported device!\n");
+   return -ENODEV;
+   }
+}
+
 static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
 const struct mcb_device_id *id)
 {
struct serial_8250_men_mcb_data *data;
struct resource *mem;
-
-   data = devm_kzalloc(>dev,
-   sizeof(struct serial_8250_men_mcb_data),
-   GFP_KERNEL);
-   if (!data)
-   return -ENOMEM;
-
-   mcb_set_drvdata(mdev, data);
-   data->uart.port.dev = mdev->dma_dev;
-   spin_lock_init(>uart.port.lock);
-
-   data->uart.port.type = PORT_16550;
-   data->uart.port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
-   data->uart.port.iotype = UPIO_MEM;
-   data->uart.port.uartclk = men_z125_lookup_uartclk(mdev);
-   data->uart.port.regshift = 0;
-   data->uart.port.fifosize = 60;
+   unsigned int num_ports;
+   unsigned int i;
+   void __iomem *membase;
 
mem = mcb_get_resource(mdev, IORESOURCE_MEM);
if (mem == NULL)
return -ENXIO;
+   membase = devm_ioremap_resource(>dev, mem);
+   if (IS_ERR(membase))
+   return PTR_ERR_OR_ZERO(membase);
 
-   data->uart.port.irq = mcb_get_irq(mdev);
+   num_ports = get_num_ports(mdev, membase);
 
-   data->uart.port.membase = devm_ioremap_resource(>dev, mem);
-   if (IS_ERR(data->uart.port.membase))
-   return PTR_ERR_OR_ZERO(data->uart.port.membase);
+   dev_dbg(>dev, "found a 16z%03u with %u ports\n",
+   mdev->id, num_ports);
 
-   data->uart.port.mapbase = (unsigned long) mem->start;
-   data->uart.port.iobase = data->uart.port.mapbase;
+   if (num_ports == 0 || num_ports > 4) {
+   dev_err(>dev, "unexpected number of ports: %u\n",
+   num_ports);
+   return -ENODEV;

Re: [PATCH v3] 8250-men-mcb: add support for 16z025 and 16z057

2018-03-05 Thread Michael Moese
Hi, sorry.. my bad. Not my day today. I forgot to commit :/

I'll resend.

On Mon, Mar 05, 2018 at 05:17:04PM +0200, Andy Shevchenko wrote:
> On Mon, Mar 5, 2018 at 10:22 AM, Michael Moese <mmo...@suse.de> wrote:
> > Add support for two MEN UARTs (16z025 and 16z057) to the
> > 8250_men_mcb driver.
> > The 16z025 consists of up to four ports, the 16z057 has
> > exactly four ports. Apart from that, all of them share the
> > Port settings.
> 
> > Changes to v2:
> > Added include of linux/io.h due to finding of kbuild robot.
> 
> Hmm... Is it there?
> 
> >  static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
> >  const struct mcb_device_id *id)
> >  {
> 
> > mem = mcb_get_resource(mdev, IORESOURCE_MEM);
> 
> > if (mem == NULL)
> > return -ENXIO;
> 
> Redundant.
> 
> > +   membase = devm_ioremap_resource(>dev, mem);
> > +   if (IS_ERR(membase))
> > +   return PTR_ERR_OR_ZERO(membase);
> 
> > +   for (i = 0; i < num_ports; i++) {
> 
> > +   /* ok, register the port */
> > +   data[i].line = serial8250_register_8250_port([i].uart);
> > +   if (data[i].line < 0) {
> > +   dev_err(>dev, "unable to register UART 
> > port\n");
> > +   return data[i].line;
> > +   }
> > +   dev_info(>dev, "found MCB UART: ttyS%d\n", 
> > data[i].line);
> 
> Consider to use  struct uart_port::name instead.
> 
> > +   }
> >
> > return 0;
> >  }
> >
> >  static void serial_8250_men_mcb_remove(struct mcb_device *mdev)
> >  {
> 
> > +   if (!data)
> > +   return;
> 
> When it's possible?
> 
> >  }
> 
> -- 
> With Best Regards,
> Andy Shevchenko


-- 
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 
(AG Nürnberg)


Re: [PATCH v3] 8250-men-mcb: add support for 16z025 and 16z057

2018-03-05 Thread Michael Moese
Hi, sorry.. my bad. Not my day today. I forgot to commit :/

I'll resend.

On Mon, Mar 05, 2018 at 05:17:04PM +0200, Andy Shevchenko wrote:
> On Mon, Mar 5, 2018 at 10:22 AM, Michael Moese  wrote:
> > Add support for two MEN UARTs (16z025 and 16z057) to the
> > 8250_men_mcb driver.
> > The 16z025 consists of up to four ports, the 16z057 has
> > exactly four ports. Apart from that, all of them share the
> > Port settings.
> 
> > Changes to v2:
> > Added include of linux/io.h due to finding of kbuild robot.
> 
> Hmm... Is it there?
> 
> >  static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
> >  const struct mcb_device_id *id)
> >  {
> 
> > mem = mcb_get_resource(mdev, IORESOURCE_MEM);
> 
> > if (mem == NULL)
> > return -ENXIO;
> 
> Redundant.
> 
> > +   membase = devm_ioremap_resource(>dev, mem);
> > +   if (IS_ERR(membase))
> > +   return PTR_ERR_OR_ZERO(membase);
> 
> > +   for (i = 0; i < num_ports; i++) {
> 
> > +   /* ok, register the port */
> > +   data[i].line = serial8250_register_8250_port([i].uart);
> > +   if (data[i].line < 0) {
> > +   dev_err(>dev, "unable to register UART 
> > port\n");
> > +   return data[i].line;
> > +   }
> > +   dev_info(>dev, "found MCB UART: ttyS%d\n", 
> > data[i].line);
> 
> Consider to use  struct uart_port::name instead.
> 
> > +   }
> >
> > return 0;
> >  }
> >
> >  static void serial_8250_men_mcb_remove(struct mcb_device *mdev)
> >  {
> 
> > +   if (!data)
> > +   return;
> 
> When it's possible?
> 
> >  }
> 
> -- 
> With Best Regards,
> Andy Shevchenko


-- 
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 
(AG Nürnberg)


[PATCH v3] 8250-men-mcb: add support for 16z025 and 16z057

2018-03-05 Thread Michael Moese
Add support for two MEN UARTs (16z025 and 16z057) to the
8250_men_mcb driver.
The 16z025 consists of up to four ports, the 16z057 has
exactly four ports. Apart from that, all of them share the
Port settings.

Signed-off-by: Michael Moese <mmo...@suse.de>
Reported-by: Ben Turner <ben.tur...@21net.com>
Tested-by: Ben Turner <ben.tur...@21net.com>

---
Changes to v2:
Added include of linux/io.h due to finding of kbuild robot.

Changes to v1:
Deduplicated the two switch() blocks into a function returning
the number of ports.
Minor style corrections.
---
 drivers/tty/serial/8250/8250_men_mcb.c | 124 -
 drivers/tty/serial/8250/Kconfig|   5 +-
 2 files changed, 93 insertions(+), 36 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_men_mcb.c 
b/drivers/tty/serial/8250/8250_men_mcb.c
index 308977807994..98b6b919bca6 100644
--- a/drivers/tty/serial/8250/8250_men_mcb.c
+++ b/drivers/tty/serial/8250/8250_men_mcb.c
@@ -7,6 +7,12 @@
 #include 
 #include 
 
+#define MEN_UART_ID_Z025 0x19
+#define MEN_UART_ID_Z057 0x39
+#define MEN_UART_ID_Z125 0x7d
+
+#define MEN_UART_MEM_SIZE 0x10
+
 struct serial_8250_men_mcb_data {
struct uart_8250_port uart;
int line;
@@ -18,7 +24,7 @@ struct serial_8250_men_mcb_data {
  * parameter in order to really set the correct baudrate, and
  * do so if possible without user interaction
  */
-static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
+static u32 men_lookup_uartclk(struct mcb_device *mdev)
 {
/* use default value if board is not available below */
u32 clkval = 1041666;
@@ -28,10 +34,12 @@ static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
mdev->bus->name);
if  (strncmp(mdev->bus->name, "F075", 4) == 0)
clkval = 1041666;
-   else if  (strncmp(mdev->bus->name, "F216", 4) == 0)
+   else if (strncmp(mdev->bus->name, "F216", 4) == 0)
clkval = 1843200;
else if (strncmp(mdev->bus->name, "G215", 4) == 0)
clkval = 1843200;
+   else if (strncmp(mdev->bus->name, "F210", 4) == 0)
+   clkval = 115200;
else
dev_info(>dev,
 "board not detected, using default uartclk\n");
@@ -41,62 +49,108 @@ static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
return clkval;
 }
 
+static unsigned int get_num_ports(struct mcb_device *mdev,
+ void __iomem *membase)
+{
+   switch (mdev->id) {
+   case MEN_UART_ID_Z125:
+   return 1U;
+   case MEN_UART_ID_Z025:
+   return readb(membase) >> 4;
+   case MEN_UART_ID_Z057:
+   return 4U;
+   default:
+   dev_err(>dev, "no supported device!\n");
+   return -ENODEV;
+   }
+}
+
 static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
 const struct mcb_device_id *id)
 {
struct serial_8250_men_mcb_data *data;
struct resource *mem;
-
-   data = devm_kzalloc(>dev,
-   sizeof(struct serial_8250_men_mcb_data),
-   GFP_KERNEL);
-   if (!data)
-   return -ENOMEM;
-
-   mcb_set_drvdata(mdev, data);
-   data->uart.port.dev = mdev->dma_dev;
-   spin_lock_init(>uart.port.lock);
-
-   data->uart.port.type = PORT_16550;
-   data->uart.port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
-   data->uart.port.iotype = UPIO_MEM;
-   data->uart.port.uartclk = men_z125_lookup_uartclk(mdev);
-   data->uart.port.regshift = 0;
-   data->uart.port.fifosize = 60;
+   unsigned int num_ports;
+   unsigned int i;
+   void __iomem *membase;
 
mem = mcb_get_resource(mdev, IORESOURCE_MEM);
if (mem == NULL)
return -ENXIO;
+   membase = devm_ioremap_resource(>dev, mem);
+   if (IS_ERR(membase))
+   return PTR_ERR_OR_ZERO(membase);
 
-   data->uart.port.irq = mcb_get_irq(mdev);
+   num_ports = get_num_ports(mdev, membase);
 
-   data->uart.port.membase = devm_ioremap_resource(>dev, mem);
-   if (IS_ERR(data->uart.port.membase))
-   return PTR_ERR_OR_ZERO(data->uart.port.membase);
+   dev_dbg(>dev, "found a 16z%03u with %u ports\n",
+   mdev->id, num_ports);
 
-   data->uart.port.mapbase = (unsigned long) mem->start;
-   data->uart.port.iobase = data->uart.port.mapbase;
+   if (num_ports == 0 || num_ports > 4) {
+   dev_err(>dev, "unexpected number of ports: %u\n",
+   num_ports);
+   return -ENODEV;
+   }
 
-   /* ok, register the port */
- 

[PATCH v3] 8250-men-mcb: add support for 16z025 and 16z057

2018-03-05 Thread Michael Moese
Add support for two MEN UARTs (16z025 and 16z057) to the
8250_men_mcb driver.
The 16z025 consists of up to four ports, the 16z057 has
exactly four ports. Apart from that, all of them share the
Port settings.

Signed-off-by: Michael Moese 
Reported-by: Ben Turner 
Tested-by: Ben Turner 

---
Changes to v2:
Added include of linux/io.h due to finding of kbuild robot.

Changes to v1:
Deduplicated the two switch() blocks into a function returning
the number of ports.
Minor style corrections.
---
 drivers/tty/serial/8250/8250_men_mcb.c | 124 -
 drivers/tty/serial/8250/Kconfig|   5 +-
 2 files changed, 93 insertions(+), 36 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_men_mcb.c 
b/drivers/tty/serial/8250/8250_men_mcb.c
index 308977807994..98b6b919bca6 100644
--- a/drivers/tty/serial/8250/8250_men_mcb.c
+++ b/drivers/tty/serial/8250/8250_men_mcb.c
@@ -7,6 +7,12 @@
 #include 
 #include 
 
+#define MEN_UART_ID_Z025 0x19
+#define MEN_UART_ID_Z057 0x39
+#define MEN_UART_ID_Z125 0x7d
+
+#define MEN_UART_MEM_SIZE 0x10
+
 struct serial_8250_men_mcb_data {
struct uart_8250_port uart;
int line;
@@ -18,7 +24,7 @@ struct serial_8250_men_mcb_data {
  * parameter in order to really set the correct baudrate, and
  * do so if possible without user interaction
  */
-static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
+static u32 men_lookup_uartclk(struct mcb_device *mdev)
 {
/* use default value if board is not available below */
u32 clkval = 1041666;
@@ -28,10 +34,12 @@ static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
mdev->bus->name);
if  (strncmp(mdev->bus->name, "F075", 4) == 0)
clkval = 1041666;
-   else if  (strncmp(mdev->bus->name, "F216", 4) == 0)
+   else if (strncmp(mdev->bus->name, "F216", 4) == 0)
clkval = 1843200;
else if (strncmp(mdev->bus->name, "G215", 4) == 0)
clkval = 1843200;
+   else if (strncmp(mdev->bus->name, "F210", 4) == 0)
+   clkval = 115200;
else
dev_info(>dev,
 "board not detected, using default uartclk\n");
@@ -41,62 +49,108 @@ static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
return clkval;
 }
 
+static unsigned int get_num_ports(struct mcb_device *mdev,
+ void __iomem *membase)
+{
+   switch (mdev->id) {
+   case MEN_UART_ID_Z125:
+   return 1U;
+   case MEN_UART_ID_Z025:
+   return readb(membase) >> 4;
+   case MEN_UART_ID_Z057:
+   return 4U;
+   default:
+   dev_err(>dev, "no supported device!\n");
+   return -ENODEV;
+   }
+}
+
 static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
 const struct mcb_device_id *id)
 {
struct serial_8250_men_mcb_data *data;
struct resource *mem;
-
-   data = devm_kzalloc(>dev,
-   sizeof(struct serial_8250_men_mcb_data),
-   GFP_KERNEL);
-   if (!data)
-   return -ENOMEM;
-
-   mcb_set_drvdata(mdev, data);
-   data->uart.port.dev = mdev->dma_dev;
-   spin_lock_init(>uart.port.lock);
-
-   data->uart.port.type = PORT_16550;
-   data->uart.port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
-   data->uart.port.iotype = UPIO_MEM;
-   data->uart.port.uartclk = men_z125_lookup_uartclk(mdev);
-   data->uart.port.regshift = 0;
-   data->uart.port.fifosize = 60;
+   unsigned int num_ports;
+   unsigned int i;
+   void __iomem *membase;
 
mem = mcb_get_resource(mdev, IORESOURCE_MEM);
if (mem == NULL)
return -ENXIO;
+   membase = devm_ioremap_resource(>dev, mem);
+   if (IS_ERR(membase))
+   return PTR_ERR_OR_ZERO(membase);
 
-   data->uart.port.irq = mcb_get_irq(mdev);
+   num_ports = get_num_ports(mdev, membase);
 
-   data->uart.port.membase = devm_ioremap_resource(>dev, mem);
-   if (IS_ERR(data->uart.port.membase))
-   return PTR_ERR_OR_ZERO(data->uart.port.membase);
+   dev_dbg(>dev, "found a 16z%03u with %u ports\n",
+   mdev->id, num_ports);
 
-   data->uart.port.mapbase = (unsigned long) mem->start;
-   data->uart.port.iobase = data->uart.port.mapbase;
+   if (num_ports == 0 || num_ports > 4) {
+   dev_err(>dev, "unexpected number of ports: %u\n",
+   num_ports);
+   return -ENODEV;
+   }
 
-   /* ok, register the port */
-   data->line = serial8250_register_8250_port(>uart);
-   if (data->line < 0)
- 

[PATCH v2] 8250-men-mcb: add support for 16z025 and 16z057

2018-02-28 Thread Michael Moese
Add support for two MEN UARTs (16z025 and 16z057) to the
8250_men_mcb driver.
The 16z025 consists of up to four ports, the 16z057 has
exactly four ports. Apart from that, all of them share the
Port settings.

Signed-off-by: Michael Moese <mmo...@suse.de>
Reported-by: Ben Turner <ben.tur...@21net.com>
Tested-by: Ben Turner <ben.tur...@21net.com>

---
Changes to v1:
Deduplicated the two switch() blocks into a function returning
the number of ports.
Minor style corrections.
---
 drivers/tty/serial/8250/8250_men_mcb.c | 124 -
 drivers/tty/serial/8250/Kconfig|   5 +-
 2 files changed, 93 insertions(+), 36 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_men_mcb.c 
b/drivers/tty/serial/8250/8250_men_mcb.c
index 308977807994..98b6b919bca6 100644
--- a/drivers/tty/serial/8250/8250_men_mcb.c
+++ b/drivers/tty/serial/8250/8250_men_mcb.c
@@ -7,6 +7,12 @@
 #include 
 #include 
 
+#define MEN_UART_ID_Z025 0x19
+#define MEN_UART_ID_Z057 0x39
+#define MEN_UART_ID_Z125 0x7d
+
+#define MEN_UART_MEM_SIZE 0x10
+
 struct serial_8250_men_mcb_data {
struct uart_8250_port uart;
int line;
@@ -18,7 +24,7 @@ struct serial_8250_men_mcb_data {
  * parameter in order to really set the correct baudrate, and
  * do so if possible without user interaction
  */
-static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
+static u32 men_lookup_uartclk(struct mcb_device *mdev)
 {
/* use default value if board is not available below */
u32 clkval = 1041666;
@@ -28,10 +34,12 @@ static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
mdev->bus->name);
if  (strncmp(mdev->bus->name, "F075", 4) == 0)
clkval = 1041666;
-   else if  (strncmp(mdev->bus->name, "F216", 4) == 0)
+   else if (strncmp(mdev->bus->name, "F216", 4) == 0)
clkval = 1843200;
else if (strncmp(mdev->bus->name, "G215", 4) == 0)
clkval = 1843200;
+   else if (strncmp(mdev->bus->name, "F210", 4) == 0)
+   clkval = 115200;
else
dev_info(>dev,
 "board not detected, using default uartclk\n");
@@ -41,62 +49,108 @@ static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
return clkval;
 }
 
+static unsigned int get_num_ports(struct mcb_device *mdev,
+ void __iomem *membase)
+{
+   switch (mdev->id) {
+   case MEN_UART_ID_Z125:
+   return 1U;
+   case MEN_UART_ID_Z025:
+   return readb(membase) >> 4;
+   case MEN_UART_ID_Z057:
+   return 4U;
+   default:
+   dev_err(>dev, "no supported device!\n");
+   return -ENODEV;
+   }
+}
+
 static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
 const struct mcb_device_id *id)
 {
struct serial_8250_men_mcb_data *data;
struct resource *mem;
-
-   data = devm_kzalloc(>dev,
-   sizeof(struct serial_8250_men_mcb_data),
-   GFP_KERNEL);
-   if (!data)
-   return -ENOMEM;
-
-   mcb_set_drvdata(mdev, data);
-   data->uart.port.dev = mdev->dma_dev;
-   spin_lock_init(>uart.port.lock);
-
-   data->uart.port.type = PORT_16550;
-   data->uart.port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
-   data->uart.port.iotype = UPIO_MEM;
-   data->uart.port.uartclk = men_z125_lookup_uartclk(mdev);
-   data->uart.port.regshift = 0;
-   data->uart.port.fifosize = 60;
+   unsigned int num_ports;
+   unsigned int i;
+   void __iomem *membase;
 
mem = mcb_get_resource(mdev, IORESOURCE_MEM);
if (mem == NULL)
return -ENXIO;
+   membase = devm_ioremap_resource(>dev, mem);
+   if (IS_ERR(membase))
+   return PTR_ERR_OR_ZERO(membase);
 
-   data->uart.port.irq = mcb_get_irq(mdev);
+   num_ports = get_num_ports(mdev, membase);
 
-   data->uart.port.membase = devm_ioremap_resource(>dev, mem);
-   if (IS_ERR(data->uart.port.membase))
-   return PTR_ERR_OR_ZERO(data->uart.port.membase);
+   dev_dbg(>dev, "found a 16z%03u with %u ports\n",
+   mdev->id, num_ports);
 
-   data->uart.port.mapbase = (unsigned long) mem->start;
-   data->uart.port.iobase = data->uart.port.mapbase;
+   if (num_ports == 0 || num_ports > 4) {
+   dev_err(>dev, "unexpected number of ports: %u\n",
+   num_ports);
+   return -ENODEV;
+   }
 
-   /* ok, register the port */
-   data->line = serial8250_register_8250_port(>uart);
-   if (data->line <

[PATCH v2] 8250-men-mcb: add support for 16z025 and 16z057

2018-02-28 Thread Michael Moese
Add support for two MEN UARTs (16z025 and 16z057) to the
8250_men_mcb driver.
The 16z025 consists of up to four ports, the 16z057 has
exactly four ports. Apart from that, all of them share the
Port settings.

Signed-off-by: Michael Moese 
Reported-by: Ben Turner 
Tested-by: Ben Turner 

---
Changes to v1:
Deduplicated the two switch() blocks into a function returning
the number of ports.
Minor style corrections.
---
 drivers/tty/serial/8250/8250_men_mcb.c | 124 -
 drivers/tty/serial/8250/Kconfig|   5 +-
 2 files changed, 93 insertions(+), 36 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_men_mcb.c 
b/drivers/tty/serial/8250/8250_men_mcb.c
index 308977807994..98b6b919bca6 100644
--- a/drivers/tty/serial/8250/8250_men_mcb.c
+++ b/drivers/tty/serial/8250/8250_men_mcb.c
@@ -7,6 +7,12 @@
 #include 
 #include 
 
+#define MEN_UART_ID_Z025 0x19
+#define MEN_UART_ID_Z057 0x39
+#define MEN_UART_ID_Z125 0x7d
+
+#define MEN_UART_MEM_SIZE 0x10
+
 struct serial_8250_men_mcb_data {
struct uart_8250_port uart;
int line;
@@ -18,7 +24,7 @@ struct serial_8250_men_mcb_data {
  * parameter in order to really set the correct baudrate, and
  * do so if possible without user interaction
  */
-static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
+static u32 men_lookup_uartclk(struct mcb_device *mdev)
 {
/* use default value if board is not available below */
u32 clkval = 1041666;
@@ -28,10 +34,12 @@ static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
mdev->bus->name);
if  (strncmp(mdev->bus->name, "F075", 4) == 0)
clkval = 1041666;
-   else if  (strncmp(mdev->bus->name, "F216", 4) == 0)
+   else if (strncmp(mdev->bus->name, "F216", 4) == 0)
clkval = 1843200;
else if (strncmp(mdev->bus->name, "G215", 4) == 0)
clkval = 1843200;
+   else if (strncmp(mdev->bus->name, "F210", 4) == 0)
+   clkval = 115200;
else
dev_info(>dev,
 "board not detected, using default uartclk\n");
@@ -41,62 +49,108 @@ static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
return clkval;
 }
 
+static unsigned int get_num_ports(struct mcb_device *mdev,
+ void __iomem *membase)
+{
+   switch (mdev->id) {
+   case MEN_UART_ID_Z125:
+   return 1U;
+   case MEN_UART_ID_Z025:
+   return readb(membase) >> 4;
+   case MEN_UART_ID_Z057:
+   return 4U;
+   default:
+   dev_err(>dev, "no supported device!\n");
+   return -ENODEV;
+   }
+}
+
 static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
 const struct mcb_device_id *id)
 {
struct serial_8250_men_mcb_data *data;
struct resource *mem;
-
-   data = devm_kzalloc(>dev,
-   sizeof(struct serial_8250_men_mcb_data),
-   GFP_KERNEL);
-   if (!data)
-   return -ENOMEM;
-
-   mcb_set_drvdata(mdev, data);
-   data->uart.port.dev = mdev->dma_dev;
-   spin_lock_init(>uart.port.lock);
-
-   data->uart.port.type = PORT_16550;
-   data->uart.port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
-   data->uart.port.iotype = UPIO_MEM;
-   data->uart.port.uartclk = men_z125_lookup_uartclk(mdev);
-   data->uart.port.regshift = 0;
-   data->uart.port.fifosize = 60;
+   unsigned int num_ports;
+   unsigned int i;
+   void __iomem *membase;
 
mem = mcb_get_resource(mdev, IORESOURCE_MEM);
if (mem == NULL)
return -ENXIO;
+   membase = devm_ioremap_resource(>dev, mem);
+   if (IS_ERR(membase))
+   return PTR_ERR_OR_ZERO(membase);
 
-   data->uart.port.irq = mcb_get_irq(mdev);
+   num_ports = get_num_ports(mdev, membase);
 
-   data->uart.port.membase = devm_ioremap_resource(>dev, mem);
-   if (IS_ERR(data->uart.port.membase))
-   return PTR_ERR_OR_ZERO(data->uart.port.membase);
+   dev_dbg(>dev, "found a 16z%03u with %u ports\n",
+   mdev->id, num_ports);
 
-   data->uart.port.mapbase = (unsigned long) mem->start;
-   data->uart.port.iobase = data->uart.port.mapbase;
+   if (num_ports == 0 || num_ports > 4) {
+   dev_err(>dev, "unexpected number of ports: %u\n",
+   num_ports);
+   return -ENODEV;
+   }
 
-   /* ok, register the port */
-   data->line = serial8250_register_8250_port(>uart);
-   if (data->line < 0)
-   return data->line;
+   data = devm_kcalloc(>dev, num_por

Re: [PATCH] 8250-men-mcb: add support for 16z025 and 16z057

2018-02-27 Thread Michael Moese
Hi,
Thanks for your comments. Let me briefly respond.

On Tue, Feb 27, 2018 at 07:57:34PM +0200, Andy Shevchenko wrote:
> On Tue, Feb 27, 2018 at 5:31 PM, Michael Moese <mmo...@suse.de> wrote:
> > -   else if  (strncmp(mdev->bus->name, "F216", 4) == 0)
> > +   else if (strncmp(mdev->bus->name, "F216", 4) == 0)
> 
> What's changed?
There were two spaces after that if.

> > +   switch (mdev->id) {
> > +   case MEN_UART_ID_Z125:
> > +   num_ports = 1U;
> > +   break;
> > +   case MEN_UART_ID_Z025:
> > +   num_ports = readb(membase) >> 4;
> > +   break;
> > +   case MEN_UART_ID_Z057:
> > +   num_ports = 4U;
> > +   break;
> > +   default:
> > +   dev_err(>dev, "no supported device!\n");
> > +   return -ENODEV;
> > +   }
> 
> (1)
> 
> > +   data[i].uart.port.mapbase = (unsigned long) mem->start
> > +   + (i * MEN_UART_MEM_SIZE);
> 
> Redundant parens.
Well, let me remove them. Gonna do a v2 anyway.

> 
> > +   switch (mdev->id) {
> > +   case MEN_UART_ID_Z125:
> > +   num_ports = 1U;
> > +   break;
> > +   case MEN_UART_ID_Z025:
> > +   num_ports = readb(data[0].uart.port.membase) >> 4;
> > +   break;
> > +   case MEN_UART_ID_Z057:
> > +   num_ports = 4U;
> > +   break;
> > +   default:
> > +   dev_err(>dev, "no supported device!\n");
> > +   return;
> > +   }
> 
> Can you deduplicate this with (1)?
Well, that sounds like a good idea. Will do this.

> -- 
> With Best Regards,
> Andy Shevchenko

Thanks,
Michael
-- 
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 
(AG Nürnberg)


Re: [PATCH] 8250-men-mcb: add support for 16z025 and 16z057

2018-02-27 Thread Michael Moese
Hi,
Thanks for your comments. Let me briefly respond.

On Tue, Feb 27, 2018 at 07:57:34PM +0200, Andy Shevchenko wrote:
> On Tue, Feb 27, 2018 at 5:31 PM, Michael Moese  wrote:
> > -   else if  (strncmp(mdev->bus->name, "F216", 4) == 0)
> > +   else if (strncmp(mdev->bus->name, "F216", 4) == 0)
> 
> What's changed?
There were two spaces after that if.

> > +   switch (mdev->id) {
> > +   case MEN_UART_ID_Z125:
> > +   num_ports = 1U;
> > +   break;
> > +   case MEN_UART_ID_Z025:
> > +   num_ports = readb(membase) >> 4;
> > +   break;
> > +   case MEN_UART_ID_Z057:
> > +   num_ports = 4U;
> > +   break;
> > +   default:
> > +   dev_err(>dev, "no supported device!\n");
> > +   return -ENODEV;
> > +   }
> 
> (1)
> 
> > +   data[i].uart.port.mapbase = (unsigned long) mem->start
> > +   + (i * MEN_UART_MEM_SIZE);
> 
> Redundant parens.
Well, let me remove them. Gonna do a v2 anyway.

> 
> > +   switch (mdev->id) {
> > +   case MEN_UART_ID_Z125:
> > +   num_ports = 1U;
> > +   break;
> > +   case MEN_UART_ID_Z025:
> > +   num_ports = readb(data[0].uart.port.membase) >> 4;
> > +   break;
> > +   case MEN_UART_ID_Z057:
> > +   num_ports = 4U;
> > +   break;
> > +   default:
> > +   dev_err(>dev, "no supported device!\n");
> > +   return;
> > +   }
> 
> Can you deduplicate this with (1)?
Well, that sounds like a good idea. Will do this.

> -- 
> With Best Regards,
> Andy Shevchenko

Thanks,
Michael
-- 
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 
(AG Nürnberg)


[PATCH] 8250-men-mcb: add support for 16z025 and 16z057

2018-02-27 Thread Michael Moese
Add support for two MEN UARTs (16z025 and 16z057) to the
8250_men_mcb driver.
The 16z025 consists of up to four ports, the 16z057 has
exactly four ports. Apart from that, all of them share the
Port settings.

Signed-off-by: Michael Moese <mmo...@suse.de>
Reported-by: Ben Turner <ben.tur...@21net.com>
Tested-by: Ben Turner <ben.tur...@21net.com>
---
 drivers/tty/serial/8250/8250_men_mcb.c | 132 -
 drivers/tty/serial/8250/Kconfig|   5 +-
 2 files changed, 100 insertions(+), 37 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_men_mcb.c 
b/drivers/tty/serial/8250/8250_men_mcb.c
index 308977807994..47abcb8d834f 100644
--- a/drivers/tty/serial/8250/8250_men_mcb.c
+++ b/drivers/tty/serial/8250/8250_men_mcb.c
@@ -7,6 +7,12 @@
 #include 
 #include 
 
+#define MEN_UART_ID_Z025 0x19
+#define MEN_UART_ID_Z057 0x39
+#define MEN_UART_ID_Z125 0x7d
+
+#define MEN_UART_MEM_SIZE 0x10
+
 struct serial_8250_men_mcb_data {
struct uart_8250_port uart;
int line;
@@ -18,7 +24,7 @@ struct serial_8250_men_mcb_data {
  * parameter in order to really set the correct baudrate, and
  * do so if possible without user interaction
  */
-static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
+static u32 men_lookup_uartclk(struct mcb_device *mdev)
 {
/* use default value if board is not available below */
u32 clkval = 1041666;
@@ -28,10 +34,12 @@ static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
mdev->bus->name);
if  (strncmp(mdev->bus->name, "F075", 4) == 0)
clkval = 1041666;
-   else if  (strncmp(mdev->bus->name, "F216", 4) == 0)
+   else if (strncmp(mdev->bus->name, "F216", 4) == 0)
clkval = 1843200;
else if (strncmp(mdev->bus->name, "G215", 4) == 0)
clkval = 1843200;
+   else if (strncmp(mdev->bus->name, "F210", 4) == 0)
+   clkval = 115200;
else
dev_info(>dev,
 "board not detected, using default uartclk\n");
@@ -46,57 +54,109 @@ static int serial_8250_men_mcb_probe(struct mcb_device 
*mdev,
 {
struct serial_8250_men_mcb_data *data;
struct resource *mem;
+   unsigned int num_ports;
+   unsigned int i;
+   void __iomem *membase;
+
+   mem = mcb_get_resource(mdev, IORESOURCE_MEM);
+   if (mem == NULL)
+   return -ENXIO;
 
-   data = devm_kzalloc(>dev,
+   membase = devm_ioremap_resource(>dev, mem);
+   if (IS_ERR(membase))
+   return PTR_ERR_OR_ZERO(membase);
+
+   switch (mdev->id) {
+   case MEN_UART_ID_Z125:
+   num_ports = 1U;
+   break;
+   case MEN_UART_ID_Z025:
+   num_ports = readb(membase) >> 4;
+   break;
+   case MEN_UART_ID_Z057:
+   num_ports = 4U;
+   break;
+   default:
+   dev_err(>dev, "no supported device!\n");
+   return -ENODEV;
+   }
+   dev_dbg(>dev, "found a 16z%03u with %u ports\n",
+   mdev->id, num_ports);
+
+   if (num_ports == 0 || num_ports > 4) {
+   dev_err(>dev, "unexpected number of ports: %u\n",
+   num_ports);
+   return -ENODEV;
+   }
+
+   data = devm_kcalloc(>dev, num_ports,
sizeof(struct serial_8250_men_mcb_data),
GFP_KERNEL);
if (!data)
return -ENOMEM;
 
mcb_set_drvdata(mdev, data);
-   data->uart.port.dev = mdev->dma_dev;
-   spin_lock_init(>uart.port.lock);
-
-   data->uart.port.type = PORT_16550;
-   data->uart.port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
-   data->uart.port.iotype = UPIO_MEM;
-   data->uart.port.uartclk = men_z125_lookup_uartclk(mdev);
-   data->uart.port.regshift = 0;
-   data->uart.port.fifosize = 60;
-
-   mem = mcb_get_resource(mdev, IORESOURCE_MEM);
-   if (mem == NULL)
-   return -ENXIO;
-
-   data->uart.port.irq = mcb_get_irq(mdev);
 
-   data->uart.port.membase = devm_ioremap_resource(>dev, mem);
-   if (IS_ERR(data->uart.port.membase))
-   return PTR_ERR_OR_ZERO(data->uart.port.membase);
-
-   data->uart.port.mapbase = (unsigned long) mem->start;
-   data->uart.port.iobase = data->uart.port.mapbase;
-
-   /* ok, register the port */
-   data->line = serial8250_register_8250_port(>uart);
-   if (data->line < 0)
-   return data->line;
-
-   dev_info(>dev, "found 16Z125 UART: ttyS%d\n", data->line);
+   for (i = 0; i < num_ports; i++) {
+   data[i].uart.port.dev = mdev->

[PATCH] 8250-men-mcb: add support for 16z025 and 16z057

2018-02-27 Thread Michael Moese
Add support for two MEN UARTs (16z025 and 16z057) to the
8250_men_mcb driver.
The 16z025 consists of up to four ports, the 16z057 has
exactly four ports. Apart from that, all of them share the
Port settings.

Signed-off-by: Michael Moese 
Reported-by: Ben Turner 
Tested-by: Ben Turner 
---
 drivers/tty/serial/8250/8250_men_mcb.c | 132 -
 drivers/tty/serial/8250/Kconfig|   5 +-
 2 files changed, 100 insertions(+), 37 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_men_mcb.c 
b/drivers/tty/serial/8250/8250_men_mcb.c
index 308977807994..47abcb8d834f 100644
--- a/drivers/tty/serial/8250/8250_men_mcb.c
+++ b/drivers/tty/serial/8250/8250_men_mcb.c
@@ -7,6 +7,12 @@
 #include 
 #include 
 
+#define MEN_UART_ID_Z025 0x19
+#define MEN_UART_ID_Z057 0x39
+#define MEN_UART_ID_Z125 0x7d
+
+#define MEN_UART_MEM_SIZE 0x10
+
 struct serial_8250_men_mcb_data {
struct uart_8250_port uart;
int line;
@@ -18,7 +24,7 @@ struct serial_8250_men_mcb_data {
  * parameter in order to really set the correct baudrate, and
  * do so if possible without user interaction
  */
-static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
+static u32 men_lookup_uartclk(struct mcb_device *mdev)
 {
/* use default value if board is not available below */
u32 clkval = 1041666;
@@ -28,10 +34,12 @@ static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
mdev->bus->name);
if  (strncmp(mdev->bus->name, "F075", 4) == 0)
clkval = 1041666;
-   else if  (strncmp(mdev->bus->name, "F216", 4) == 0)
+   else if (strncmp(mdev->bus->name, "F216", 4) == 0)
clkval = 1843200;
else if (strncmp(mdev->bus->name, "G215", 4) == 0)
clkval = 1843200;
+   else if (strncmp(mdev->bus->name, "F210", 4) == 0)
+   clkval = 115200;
else
dev_info(>dev,
 "board not detected, using default uartclk\n");
@@ -46,57 +54,109 @@ static int serial_8250_men_mcb_probe(struct mcb_device 
*mdev,
 {
struct serial_8250_men_mcb_data *data;
struct resource *mem;
+   unsigned int num_ports;
+   unsigned int i;
+   void __iomem *membase;
+
+   mem = mcb_get_resource(mdev, IORESOURCE_MEM);
+   if (mem == NULL)
+   return -ENXIO;
 
-   data = devm_kzalloc(>dev,
+   membase = devm_ioremap_resource(>dev, mem);
+   if (IS_ERR(membase))
+   return PTR_ERR_OR_ZERO(membase);
+
+   switch (mdev->id) {
+   case MEN_UART_ID_Z125:
+   num_ports = 1U;
+   break;
+   case MEN_UART_ID_Z025:
+   num_ports = readb(membase) >> 4;
+   break;
+   case MEN_UART_ID_Z057:
+   num_ports = 4U;
+   break;
+   default:
+   dev_err(>dev, "no supported device!\n");
+   return -ENODEV;
+   }
+   dev_dbg(>dev, "found a 16z%03u with %u ports\n",
+   mdev->id, num_ports);
+
+   if (num_ports == 0 || num_ports > 4) {
+   dev_err(>dev, "unexpected number of ports: %u\n",
+   num_ports);
+   return -ENODEV;
+   }
+
+   data = devm_kcalloc(>dev, num_ports,
sizeof(struct serial_8250_men_mcb_data),
GFP_KERNEL);
if (!data)
return -ENOMEM;
 
mcb_set_drvdata(mdev, data);
-   data->uart.port.dev = mdev->dma_dev;
-   spin_lock_init(>uart.port.lock);
-
-   data->uart.port.type = PORT_16550;
-   data->uart.port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
-   data->uart.port.iotype = UPIO_MEM;
-   data->uart.port.uartclk = men_z125_lookup_uartclk(mdev);
-   data->uart.port.regshift = 0;
-   data->uart.port.fifosize = 60;
-
-   mem = mcb_get_resource(mdev, IORESOURCE_MEM);
-   if (mem == NULL)
-   return -ENXIO;
-
-   data->uart.port.irq = mcb_get_irq(mdev);
 
-   data->uart.port.membase = devm_ioremap_resource(>dev, mem);
-   if (IS_ERR(data->uart.port.membase))
-   return PTR_ERR_OR_ZERO(data->uart.port.membase);
-
-   data->uart.port.mapbase = (unsigned long) mem->start;
-   data->uart.port.iobase = data->uart.port.mapbase;
-
-   /* ok, register the port */
-   data->line = serial8250_register_8250_port(>uart);
-   if (data->line < 0)
-   return data->line;
-
-   dev_info(>dev, "found 16Z125 UART: ttyS%d\n", data->line);
+   for (i = 0; i < num_ports; i++) {
+   data[i].uart.port.dev = mdev->dma_dev;
+   spin_lock_init([i].uart.port.lock);
+
+  

Re: [PATCH 2/2] mcb: add Altera PCI ID to mcb-pci

2018-02-27 Thread Michael Moese
Looks good.

Reviewed-by: Michael Moese <mmo...@suse.de>


On Tue, Feb 27, 2018 at 02:30:18PM +0100, Johannes Thumshirn wrote:
> Some older PCI attached MEN FPGAs use an Altera PCI Vendor ID instead
> of the MEN one. Add it to the PCI ID table so the driver automatically
> attaches to it.
> 
> Signed-off-by: Johannes Thumshirn <jthumsh...@suse.de>
> Reported-by: Ben Turner <ben.tur...@21net.com>
> Tested-by: Ben Turner <ben.tur...@21net.com>
> Cc: Andreas Geißler <andreas.geiss...@men.de>
> Cc: Michael Moese <mmo...@suse.de>
> ---
>  drivers/mcb/mcb-pci.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/mcb/mcb-pci.c b/drivers/mcb/mcb-pci.c
> index af4d2f26f1c6..286b32ca526f 100644
> --- a/drivers/mcb/mcb-pci.c
> +++ b/drivers/mcb/mcb-pci.c
> @@ -11,6 +11,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include "mcb-internal.h"
> @@ -117,6 +118,7 @@ static void mcb_pci_remove(struct pci_dev *pdev)
>  
>  static const struct pci_device_id mcb_pci_tbl[] = {
>   { PCI_DEVICE(PCI_VENDOR_ID_MEN, PCI_DEVICE_ID_MEN_CHAMELEON) },
> + { PCI_DEVICE(PCI_VENDOR_ID_ALTERA, PCI_DEVICE_ID_MEN_CHAMELEON) },
>   { 0 },
>  };
>  MODULE_DEVICE_TABLE(pci, mcb_pci_tbl);
> -- 
> 2.13.6
> 

-- 
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 
(AG Nürnberg)


Re: [PATCH 2/2] mcb: add Altera PCI ID to mcb-pci

2018-02-27 Thread Michael Moese
Looks good.

Reviewed-by: Michael Moese 


On Tue, Feb 27, 2018 at 02:30:18PM +0100, Johannes Thumshirn wrote:
> Some older PCI attached MEN FPGAs use an Altera PCI Vendor ID instead
> of the MEN one. Add it to the PCI ID table so the driver automatically
> attaches to it.
> 
> Signed-off-by: Johannes Thumshirn 
> Reported-by: Ben Turner 
> Tested-by: Ben Turner 
> Cc: Andreas Geißler 
> Cc: Michael Moese 
> ---
>  drivers/mcb/mcb-pci.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/mcb/mcb-pci.c b/drivers/mcb/mcb-pci.c
> index af4d2f26f1c6..286b32ca526f 100644
> --- a/drivers/mcb/mcb-pci.c
> +++ b/drivers/mcb/mcb-pci.c
> @@ -11,6 +11,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include "mcb-internal.h"
> @@ -117,6 +118,7 @@ static void mcb_pci_remove(struct pci_dev *pdev)
>  
>  static const struct pci_device_id mcb_pci_tbl[] = {
>   { PCI_DEVICE(PCI_VENDOR_ID_MEN, PCI_DEVICE_ID_MEN_CHAMELEON) },
> + { PCI_DEVICE(PCI_VENDOR_ID_ALTERA, PCI_DEVICE_ID_MEN_CHAMELEON) },
>   { 0 },
>  };
>  MODULE_DEVICE_TABLE(pci, mcb_pci_tbl);
> -- 
> 2.13.6
> 

-- 
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 
(AG Nürnberg)


[PATCH] Introduce dmam_zalloc_coherent()

2017-08-08 Thread Michael Moese
All memory allocation functions have a pendant for allocating zeroed
memory, but dmam_alloc_coherent does not have such a pendant.
However, it is easier to read dmam_zalloc_coherent than passing an extra
flag or, even worse, see memset() after the allocation.
This patch adds an inline function dmam_zalloc_coherent(), exactly like
the implementation of dma_zalloc_coherent().

Signed-off-by: Michael Moese <michael.mo...@men.de>
---
 include/linux/dma-mapping.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 03c0196a6f24..cf6cbda76ee2 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -761,6 +761,15 @@ extern void dmam_free_coherent(struct device *dev, size_t 
size, void *vaddr,
 extern void *dmam_alloc_attrs(struct device *dev, size_t size,
  dma_addr_t *dma_handle, gfp_t gfp,
  unsigned long attrs);
+
+static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
+   dma_addr_t *dma_handle, gfp_t flag)
+{
+   void *ret = dmam_alloc_coherent(dev, size, dma_handle,
+   flag | __GFP_ZERO);
+   return ret;
+}
+
 #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT
 extern int dmam_declare_coherent_memory(struct device *dev,
phys_addr_t phys_addr,
-- 
2.13.1



[PATCH] Introduce dmam_zalloc_coherent()

2017-08-08 Thread Michael Moese
All memory allocation functions have a pendant for allocating zeroed
memory, but dmam_alloc_coherent does not have such a pendant.
However, it is easier to read dmam_zalloc_coherent than passing an extra
flag or, even worse, see memset() after the allocation.
This patch adds an inline function dmam_zalloc_coherent(), exactly like
the implementation of dma_zalloc_coherent().

Signed-off-by: Michael Moese 
---
 include/linux/dma-mapping.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 03c0196a6f24..cf6cbda76ee2 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -761,6 +761,15 @@ extern void dmam_free_coherent(struct device *dev, size_t 
size, void *vaddr,
 extern void *dmam_alloc_attrs(struct device *dev, size_t size,
  dma_addr_t *dma_handle, gfp_t gfp,
  unsigned long attrs);
+
+static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
+   dma_addr_t *dma_handle, gfp_t flag)
+{
+   void *ret = dmam_alloc_coherent(dev, size, dma_handle,
+   flag | __GFP_ZERO);
+   return ret;
+}
+
 #ifdef CONFIG_HAVE_GENERIC_DMA_COHERENT
 extern int dmam_declare_coherent_memory(struct device *dev,
phys_addr_t phys_addr,
-- 
2.13.1



[PATCH v2 1/2] mcb: introduce mcb_get_resource()

2017-08-02 Thread Michael Moese
From: Johannes Thumshirn 

Introduce mcb_get_resource() as a common accessor to a mcb device's memory or
IRQ resources.

Signed-off-by: Johannes Thumshirn 
---
 drivers/mcb/mcb-core.c | 20 +++-
 include/linux/mcb.h|  2 ++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index 921a5d2a802b..bb5c5692dedc 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -418,6 +418,22 @@ void mcb_bus_add_devices(const struct mcb_bus *bus)
 EXPORT_SYMBOL_GPL(mcb_bus_add_devices);
 
 /**
+ * mcb_get_resource() - get a resource for a mcb device
+ * @dev: the mcb device
+ * @type: the type of resource
+ */
+struct resource *mcb_get_resource(struct mcb_device *dev, unsigned int type)
+{
+   if (type == IORESOURCE_MEM)
+   return >mem;
+   else if (type == IORESOURCE_IRQ)
+   return >irq;
+   else
+   return NULL;
+}
+EXPORT_SYMBOL_GPL(mcb_get_resource);
+
+/**
  * mcb_request_mem() - Request memory
  * @dev: The @mcb_device the memory is for
  * @name: The name for the memory reference.
@@ -460,7 +476,9 @@ EXPORT_SYMBOL_GPL(mcb_release_mem);
 
 static int __mcb_get_irq(struct mcb_device *dev)
 {
-   struct resource *irq = >irq;
+   struct resource *irq;
+
+   irq = mcb_get_resource(dev, IORESOURCE_IRQ);
 
return irq->start;
 }
diff --git a/include/linux/mcb.h b/include/linux/mcb.h
index 4097ac9ea13a..b1a0ad9d23b3 100644
--- a/include/linux/mcb.h
+++ b/include/linux/mcb.h
@@ -136,5 +136,7 @@ extern struct resource *mcb_request_mem(struct mcb_device 
*dev,
const char *name);
 extern void mcb_release_mem(struct resource *mem);
 extern int mcb_get_irq(struct mcb_device *dev);
+extern struct resource *mcb_get_resource(struct mcb_device *dev,
+unsigned int type);
 
 #endif /* _LINUX_MCB_H */
-- 
2.12.3



[PATCH v2 1/2] mcb: introduce mcb_get_resource()

2017-08-02 Thread Michael Moese
From: Johannes Thumshirn 

Introduce mcb_get_resource() as a common accessor to a mcb device's memory or
IRQ resources.

Signed-off-by: Johannes Thumshirn 
---
 drivers/mcb/mcb-core.c | 20 +++-
 include/linux/mcb.h|  2 ++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index 921a5d2a802b..bb5c5692dedc 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -418,6 +418,22 @@ void mcb_bus_add_devices(const struct mcb_bus *bus)
 EXPORT_SYMBOL_GPL(mcb_bus_add_devices);
 
 /**
+ * mcb_get_resource() - get a resource for a mcb device
+ * @dev: the mcb device
+ * @type: the type of resource
+ */
+struct resource *mcb_get_resource(struct mcb_device *dev, unsigned int type)
+{
+   if (type == IORESOURCE_MEM)
+   return >mem;
+   else if (type == IORESOURCE_IRQ)
+   return >irq;
+   else
+   return NULL;
+}
+EXPORT_SYMBOL_GPL(mcb_get_resource);
+
+/**
  * mcb_request_mem() - Request memory
  * @dev: The @mcb_device the memory is for
  * @name: The name for the memory reference.
@@ -460,7 +476,9 @@ EXPORT_SYMBOL_GPL(mcb_release_mem);
 
 static int __mcb_get_irq(struct mcb_device *dev)
 {
-   struct resource *irq = >irq;
+   struct resource *irq;
+
+   irq = mcb_get_resource(dev, IORESOURCE_IRQ);
 
return irq->start;
 }
diff --git a/include/linux/mcb.h b/include/linux/mcb.h
index 4097ac9ea13a..b1a0ad9d23b3 100644
--- a/include/linux/mcb.h
+++ b/include/linux/mcb.h
@@ -136,5 +136,7 @@ extern struct resource *mcb_request_mem(struct mcb_device 
*dev,
const char *name);
 extern void mcb_release_mem(struct resource *mem);
 extern int mcb_get_irq(struct mcb_device *dev);
+extern struct resource *mcb_get_resource(struct mcb_device *dev,
+unsigned int type);
 
 #endif /* _LINUX_MCB_H */
-- 
2.12.3



[PATCH v2 2/2] Introduce 8250_men_mcb

2017-08-02 Thread Michael Moese
This patch introduces the 8250_men_mcb driver for the MEN 16Z125
IP-Core. This is a 16550-type UART with a 60 byte FIFO.
Due to strange old hardware, every board using this IP core requires
different values for uartclk. A reasonable default is included in
addition to the support of three boards. Additional values for other
boards will be added later.

This v2 has some whitespace fixes, I screwed this up yesterday.

Signed-off-by: Michael Moese <michael.mo...@men.de>
---
 drivers/tty/serial/8250/8250_men_mcb.c | 118 +
 drivers/tty/serial/8250/Kconfig|  11 +++
 drivers/tty/serial/8250/Makefile   |   1 +
 3 files changed, 130 insertions(+)
 create mode 100644 drivers/tty/serial/8250/8250_men_mcb.c

diff --git a/drivers/tty/serial/8250/8250_men_mcb.c 
b/drivers/tty/serial/8250/8250_men_mcb.c
new file mode 100644
index ..308977807994
--- /dev/null
+++ b/drivers/tty/serial/8250/8250_men_mcb.c
@@ -0,0 +1,118 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct serial_8250_men_mcb_data {
+   struct uart_8250_port uart;
+   int line;
+};
+
+/*
+ * The Z125 16550-compatible UART has no fixed base clock assigned
+ * So, depending on the board we're on, we need to adjust the
+ * parameter in order to really set the correct baudrate, and
+ * do so if possible without user interaction
+ */
+static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
+{
+   /* use default value if board is not available below */
+   u32 clkval = 1041666;
+
+   dev_info(>dev, "%s on board %s\n",
+   dev_name(>dev),
+   mdev->bus->name);
+   if  (strncmp(mdev->bus->name, "F075", 4) == 0)
+   clkval = 1041666;
+   else if  (strncmp(mdev->bus->name, "F216", 4) == 0)
+   clkval = 1843200;
+   else if (strncmp(mdev->bus->name, "G215", 4) == 0)
+   clkval = 1843200;
+   else
+   dev_info(>dev,
+"board not detected, using default uartclk\n");
+
+   clkval = clkval  << 4;
+
+   return clkval;
+}
+
+static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
+const struct mcb_device_id *id)
+{
+   struct serial_8250_men_mcb_data *data;
+   struct resource *mem;
+
+   data = devm_kzalloc(>dev,
+   sizeof(struct serial_8250_men_mcb_data),
+   GFP_KERNEL);
+   if (!data)
+   return -ENOMEM;
+
+   mcb_set_drvdata(mdev, data);
+   data->uart.port.dev = mdev->dma_dev;
+   spin_lock_init(>uart.port.lock);
+
+   data->uart.port.type = PORT_16550;
+   data->uart.port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
+   data->uart.port.iotype = UPIO_MEM;
+   data->uart.port.uartclk = men_z125_lookup_uartclk(mdev);
+   data->uart.port.regshift = 0;
+   data->uart.port.fifosize = 60;
+
+   mem = mcb_get_resource(mdev, IORESOURCE_MEM);
+   if (mem == NULL)
+   return -ENXIO;
+
+   data->uart.port.irq = mcb_get_irq(mdev);
+
+   data->uart.port.membase = devm_ioremap_resource(>dev, mem);
+   if (IS_ERR(data->uart.port.membase))
+   return PTR_ERR_OR_ZERO(data->uart.port.membase);
+
+   data->uart.port.mapbase = (unsigned long) mem->start;
+   data->uart.port.iobase = data->uart.port.mapbase;
+
+   /* ok, register the port */
+   data->line = serial8250_register_8250_port(>uart);
+   if (data->line < 0)
+   return data->line;
+
+   dev_info(>dev, "found 16Z125 UART: ttyS%d\n", data->line);
+
+   return 0;
+}
+
+static void serial_8250_men_mcb_remove(struct mcb_device *mdev)
+{
+   struct serial_8250_men_mcb_data *data = mcb_get_drvdata(mdev);
+
+   if (data)
+   serial8250_unregister_port(data->line);
+}
+
+static const struct mcb_device_id serial_8250_men_mcb_ids[] = {
+   { .device = 0x7d },
+   { }
+};
+MODULE_DEVICE_TABLE(mcb, serial_8250_men_mcb_ids);
+
+static struct mcb_driver mcb_driver = {
+   .driver = {
+   .name = "8250_men_mcb",
+   .owner = THIS_MODULE,
+   },
+   .probe = serial_8250_men_mcb_probe,
+   .remove = serial_8250_men_mcb_remove,
+   .id_table = serial_8250_men_mcb_ids,
+};
+module_mcb_driver(mcb_driver);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("MEN 16z125 8250 UART driver");
+MODULE_AUTHOR("Michael Moese <michael.mo...@men.de");
+MODULE_ALIAS("mcb:16z125");
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig
index a1161ec0256f..a5c0ef1e7695 100644
--- a/drivers/tty/serial/8250/Kconfig
+++ b/drivers/tty/serial/8250/K

[PATCH v2 2/2] Introduce 8250_men_mcb

2017-08-02 Thread Michael Moese
This patch introduces the 8250_men_mcb driver for the MEN 16Z125
IP-Core. This is a 16550-type UART with a 60 byte FIFO.
Due to strange old hardware, every board using this IP core requires
different values for uartclk. A reasonable default is included in
addition to the support of three boards. Additional values for other
boards will be added later.

This v2 has some whitespace fixes, I screwed this up yesterday.

Signed-off-by: Michael Moese 
---
 drivers/tty/serial/8250/8250_men_mcb.c | 118 +
 drivers/tty/serial/8250/Kconfig|  11 +++
 drivers/tty/serial/8250/Makefile   |   1 +
 3 files changed, 130 insertions(+)
 create mode 100644 drivers/tty/serial/8250/8250_men_mcb.c

diff --git a/drivers/tty/serial/8250/8250_men_mcb.c 
b/drivers/tty/serial/8250/8250_men_mcb.c
new file mode 100644
index ..308977807994
--- /dev/null
+++ b/drivers/tty/serial/8250/8250_men_mcb.c
@@ -0,0 +1,118 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct serial_8250_men_mcb_data {
+   struct uart_8250_port uart;
+   int line;
+};
+
+/*
+ * The Z125 16550-compatible UART has no fixed base clock assigned
+ * So, depending on the board we're on, we need to adjust the
+ * parameter in order to really set the correct baudrate, and
+ * do so if possible without user interaction
+ */
+static u32 men_z125_lookup_uartclk(struct mcb_device *mdev)
+{
+   /* use default value if board is not available below */
+   u32 clkval = 1041666;
+
+   dev_info(>dev, "%s on board %s\n",
+   dev_name(>dev),
+   mdev->bus->name);
+   if  (strncmp(mdev->bus->name, "F075", 4) == 0)
+   clkval = 1041666;
+   else if  (strncmp(mdev->bus->name, "F216", 4) == 0)
+   clkval = 1843200;
+   else if (strncmp(mdev->bus->name, "G215", 4) == 0)
+   clkval = 1843200;
+   else
+   dev_info(>dev,
+"board not detected, using default uartclk\n");
+
+   clkval = clkval  << 4;
+
+   return clkval;
+}
+
+static int serial_8250_men_mcb_probe(struct mcb_device *mdev,
+const struct mcb_device_id *id)
+{
+   struct serial_8250_men_mcb_data *data;
+   struct resource *mem;
+
+   data = devm_kzalloc(>dev,
+   sizeof(struct serial_8250_men_mcb_data),
+   GFP_KERNEL);
+   if (!data)
+   return -ENOMEM;
+
+   mcb_set_drvdata(mdev, data);
+   data->uart.port.dev = mdev->dma_dev;
+   spin_lock_init(>uart.port.lock);
+
+   data->uart.port.type = PORT_16550;
+   data->uart.port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
+   data->uart.port.iotype = UPIO_MEM;
+   data->uart.port.uartclk = men_z125_lookup_uartclk(mdev);
+   data->uart.port.regshift = 0;
+   data->uart.port.fifosize = 60;
+
+   mem = mcb_get_resource(mdev, IORESOURCE_MEM);
+   if (mem == NULL)
+   return -ENXIO;
+
+   data->uart.port.irq = mcb_get_irq(mdev);
+
+   data->uart.port.membase = devm_ioremap_resource(>dev, mem);
+   if (IS_ERR(data->uart.port.membase))
+   return PTR_ERR_OR_ZERO(data->uart.port.membase);
+
+   data->uart.port.mapbase = (unsigned long) mem->start;
+   data->uart.port.iobase = data->uart.port.mapbase;
+
+   /* ok, register the port */
+   data->line = serial8250_register_8250_port(>uart);
+   if (data->line < 0)
+   return data->line;
+
+   dev_info(>dev, "found 16Z125 UART: ttyS%d\n", data->line);
+
+   return 0;
+}
+
+static void serial_8250_men_mcb_remove(struct mcb_device *mdev)
+{
+   struct serial_8250_men_mcb_data *data = mcb_get_drvdata(mdev);
+
+   if (data)
+   serial8250_unregister_port(data->line);
+}
+
+static const struct mcb_device_id serial_8250_men_mcb_ids[] = {
+   { .device = 0x7d },
+   { }
+};
+MODULE_DEVICE_TABLE(mcb, serial_8250_men_mcb_ids);
+
+static struct mcb_driver mcb_driver = {
+   .driver = {
+   .name = "8250_men_mcb",
+   .owner = THIS_MODULE,
+   },
+   .probe = serial_8250_men_mcb_probe,
+   .remove = serial_8250_men_mcb_remove,
+   .id_table = serial_8250_men_mcb_ids,
+};
+module_mcb_driver(mcb_driver);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("MEN 16z125 8250 UART driver");
+MODULE_AUTHOR("Michael Moese 

[PATCH] MCB: add support for SC31 to mcb-lpc

2017-08-01 Thread Michael Moese
This patch adds the resources and DMI ID's for the MEN SC31,
which uses a different address region to map the LPC bus than
the one used for the existing SC24.

Signed-off-by: Michael Moese <michael.mo...@men.de>
---
 drivers/mcb/mcb-lpc.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/mcb/mcb-lpc.c b/drivers/mcb/mcb-lpc.c
index d072c088ce73..945091a88354 100644
--- a/drivers/mcb/mcb-lpc.c
+++ b/drivers/mcb/mcb-lpc.c
@@ -114,6 +114,12 @@ static struct resource sc24_fpga_resource = {
.flags = IORESOURCE_MEM,
 };
 
+static struct resource sc31_fpga_resource = {
+   .start = 0xf000e000,
+   .end = 0xf000e000 + CHAM_HEADER_SIZE,
+   .flags = IORESOURCE_MEM,
+};
+
 static struct platform_driver mcb_lpc_driver = {
.driver = {
.name = "mcb-lpc",
@@ -132,6 +138,15 @@ static const struct dmi_system_id mcb_lpc_dmi_table[] = {
.driver_data = (void *)_fpga_resource,
.callback = mcb_lpc_create_platform_device,
},
+   {
+   .ident = "SC31",
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "MEN"),
+   DMI_MATCH(DMI_PRODUCT_VERSION, "14SC31"),
+   },
+   .driver_data = (void *)_fpga_resource,
+   .callback = mcb_lpc_create_platform_device,
+   },
{}
 };
 MODULE_DEVICE_TABLE(dmi, mcb_lpc_dmi_table);
-- 
2.12.3



[PATCH] MCB: add support for SC31 to mcb-lpc

2017-08-01 Thread Michael Moese
This patch adds the resources and DMI ID's for the MEN SC31,
which uses a different address region to map the LPC bus than
the one used for the existing SC24.

Signed-off-by: Michael Moese 
---
 drivers/mcb/mcb-lpc.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/mcb/mcb-lpc.c b/drivers/mcb/mcb-lpc.c
index d072c088ce73..945091a88354 100644
--- a/drivers/mcb/mcb-lpc.c
+++ b/drivers/mcb/mcb-lpc.c
@@ -114,6 +114,12 @@ static struct resource sc24_fpga_resource = {
.flags = IORESOURCE_MEM,
 };
 
+static struct resource sc31_fpga_resource = {
+   .start = 0xf000e000,
+   .end = 0xf000e000 + CHAM_HEADER_SIZE,
+   .flags = IORESOURCE_MEM,
+};
+
 static struct platform_driver mcb_lpc_driver = {
.driver = {
.name = "mcb-lpc",
@@ -132,6 +138,15 @@ static const struct dmi_system_id mcb_lpc_dmi_table[] = {
.driver_data = (void *)_fpga_resource,
.callback = mcb_lpc_create_platform_device,
},
+   {
+   .ident = "SC31",
+   .matches = {
+   DMI_MATCH(DMI_SYS_VENDOR, "MEN"),
+   DMI_MATCH(DMI_PRODUCT_VERSION, "14SC31"),
+   },
+   .driver_data = (void *)_fpga_resource,
+   .callback = mcb_lpc_create_platform_device,
+   },
{}
 };
 MODULE_DEVICE_TABLE(dmi, mcb_lpc_dmi_table);
-- 
2.12.3



[PATCH] Added SIOCSMIIREG (mii write) support to intel igb driver

2017-06-22 Thread Michael Moese
From: Andreas Werner 

Signed-off-by: Andreas Werner 
---
 drivers/net/ethernet/intel/igb/igb_main.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index 1cf74aa4ebd9..87e496eeefb1 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -7716,6 +7716,10 @@ static int igb_mii_ioctl(struct net_device *netdev, 
struct ifreq *ifr, int cmd)
return -EIO;
break;
case SIOCSMIIREG:
+   if (igb_write_phy_reg(>hw, data->reg_num & 0x1F,
+ data->val_in))
+   return -EIO;
+   break;
default:
return -EOPNOTSUPP;
}
-- 
2.12.3



[PATCH] Added SIOCSMIIREG (mii write) support to intel igb driver

2017-06-22 Thread Michael Moese
From: Andreas Werner 

Signed-off-by: Andreas Werner 
---
 drivers/net/ethernet/intel/igb/igb_main.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index 1cf74aa4ebd9..87e496eeefb1 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -7716,6 +7716,10 @@ static int igb_mii_ioctl(struct net_device *netdev, 
struct ifreq *ifr, int cmd)
return -EIO;
break;
case SIOCSMIIREG:
+   if (igb_write_phy_reg(>hw, data->reg_num & 0x1F,
+ data->val_in))
+   return -EIO;
+   break;
default:
return -EOPNOTSUPP;
}
-- 
2.12.3



[PATCH] mcb: fix compiler warning logical-op in mcb-parse.c

2016-10-19 Thread Michael Moese
The expression was clearly wrong, the logical AND of expressions
must be changed to a logical OR.

Reported-by: David Binderman <dcb...@hotmail.com>
Signed-off-by: Michael Moese <michael.mo...@men.de>
---
 drivers/mcb/mcb-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mcb/mcb-parse.c b/drivers/mcb/mcb-parse.c
index 4ca2739..ee7fb6e 100644
--- a/drivers/mcb/mcb-parse.c
+++ b/drivers/mcb/mcb-parse.c
@@ -149,7 +149,7 @@ static int chameleon_get_bar(char __iomem **base, 
phys_addr_t mapbase,
reg = readl(*base);
 
bar_count = BAR_CNT(reg);
-   if (bar_count <= 0 && bar_count > CHAMELEON_BAR_MAX)
+   if (bar_count <= 0 || bar_count > CHAMELEON_BAR_MAX)
return -ENODEV;
 
c = kcalloc(bar_count, sizeof(struct chameleon_bar),
-- 
2.10.0



[PATCH] mcb: fix compiler warning logical-op in mcb-parse.c

2016-10-19 Thread Michael Moese
The expression was clearly wrong, the logical AND of expressions
must be changed to a logical OR.

Reported-by: David Binderman 
Signed-off-by: Michael Moese 
---
 drivers/mcb/mcb-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mcb/mcb-parse.c b/drivers/mcb/mcb-parse.c
index 4ca2739..ee7fb6e 100644
--- a/drivers/mcb/mcb-parse.c
+++ b/drivers/mcb/mcb-parse.c
@@ -149,7 +149,7 @@ static int chameleon_get_bar(char __iomem **base, 
phys_addr_t mapbase,
reg = readl(*base);
 
bar_count = BAR_CNT(reg);
-   if (bar_count <= 0 && bar_count > CHAMELEON_BAR_MAX)
+   if (bar_count <= 0 || bar_count > CHAMELEON_BAR_MAX)
return -ENODEV;
 
c = kcalloc(bar_count, sizeof(struct chameleon_bar),
-- 
2.10.0



[PATCH v2 2/2] Add a dma_device to mcb_device

2016-08-29 Thread Michael Moese
When performing DMA operations on a MCB device, the device needed
for using the DMA API is "mcb_device->bus_carrier".
This is rather lengthy, so a shortcut is introduced to struct mcb_device
in order to ensure the MCB device driver uses the correct device for DMA
operations.

Signed-off-by: Michael Moese <michael.mo...@men.de>
---
 drivers/mcb/mcb-core.c | 1 +
 include/linux/mcb.h| 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index 5306966..921a5d2 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -233,6 +233,7 @@ int mcb_device_register(struct mcb_bus *bus, struct 
mcb_device *dev)
dev->dev.bus = _bus_type;
dev->dev.parent = bus->dev.parent;
dev->dev.release = mcb_release_dev;
+   dev->dma_dev = bus->carrier;
 
device_id = dev->id;
dev_set_name(>dev, "mcb%d-16z%03d-%d:%d:%d",
diff --git a/include/linux/mcb.h b/include/linux/mcb.h
index ee5200d..4097ac9 100644
--- a/include/linux/mcb.h
+++ b/include/linux/mcb.h
@@ -76,6 +76,7 @@ struct mcb_device {
int rev;
struct resource irq;
struct resource mem;
+   struct device *dma_dev;
 };
 
 static inline struct mcb_device *to_mcb_device(struct device *dev)
-- 
2.6.6



[PATCH v2 2/2] Add a dma_device to mcb_device

2016-08-29 Thread Michael Moese
When performing DMA operations on a MCB device, the device needed
for using the DMA API is "mcb_device->bus_carrier".
This is rather lengthy, so a shortcut is introduced to struct mcb_device
in order to ensure the MCB device driver uses the correct device for DMA
operations.

Signed-off-by: Michael Moese 
---
 drivers/mcb/mcb-core.c | 1 +
 include/linux/mcb.h| 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index 5306966..921a5d2 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -233,6 +233,7 @@ int mcb_device_register(struct mcb_bus *bus, struct 
mcb_device *dev)
dev->dev.bus = _bus_type;
dev->dev.parent = bus->dev.parent;
dev->dev.release = mcb_release_dev;
+   dev->dma_dev = bus->carrier;
 
device_id = dev->id;
dev_set_name(>dev, "mcb%d-16z%03d-%d:%d:%d",
diff --git a/include/linux/mcb.h b/include/linux/mcb.h
index ee5200d..4097ac9 100644
--- a/include/linux/mcb.h
+++ b/include/linux/mcb.h
@@ -76,6 +76,7 @@ struct mcb_device {
int rev;
struct resource irq;
struct resource mem;
+   struct device *dma_dev;
 };
 
 static inline struct mcb_device *to_mcb_device(struct device *dev)
-- 
2.6.6



[PATCH v2 1/2] Enable PCI bus mastering by default

2016-08-29 Thread Michael Moese
In order to successfully perform DMA operations on PCI devices,
it is necessary to enble PCI bus mastering, so enable it by default.

Signed-off-by: Michael Moese <michael.mo...@men.de>
---
 drivers/mcb/mcb-pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mcb/mcb-pci.c b/drivers/mcb/mcb-pci.c
index b15a034..af4d2f2 100644
--- a/drivers/mcb/mcb-pci.c
+++ b/drivers/mcb/mcb-pci.c
@@ -46,6 +46,7 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
dev_err(>dev, "Failed to enable PCI device\n");
return -ENODEV;
}
+   pci_set_master(pdev);
 
priv->mapbase = pci_resource_start(pdev, 0);
if (!priv->mapbase) {
-- 
2.6.6



[PATCH v2 1/2] Enable PCI bus mastering by default

2016-08-29 Thread Michael Moese
In order to successfully perform DMA operations on PCI devices,
it is necessary to enble PCI bus mastering, so enable it by default.

Signed-off-by: Michael Moese 
---
 drivers/mcb/mcb-pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mcb/mcb-pci.c b/drivers/mcb/mcb-pci.c
index b15a034..af4d2f2 100644
--- a/drivers/mcb/mcb-pci.c
+++ b/drivers/mcb/mcb-pci.c
@@ -46,6 +46,7 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
dev_err(>dev, "Failed to enable PCI device\n");
return -ENODEV;
}
+   pci_set_master(pdev);
 
priv->mapbase = pci_resource_start(pdev, 0);
if (!priv->mapbase) {
-- 
2.6.6



[PATCH v2 0/2] Add (PCI) DMA support to MCB.

2016-08-29 Thread Michael Moese
This is v2 of this patch series.
The first series had missing commit logs and named the dma_dev differently 
in include/linux/mcb.h and drivers/mcb/mcb-core.c. 

This small series of two patches enable (PCI) DMA support in MCB.

The first patch enables PCI bus mastering by default for all PCI-based MCB 
devices.

The second patch adds a dma_device to the mcb_device for all devices as a 
shortcut to mcb_device->bus->carrier.


Michael Moese (2):
  Enable PCI bus mastering by default
  Add a dma_device to mcb_device

 drivers/mcb/mcb-core.c | 1 +
 drivers/mcb/mcb-pci.c  | 1 +
 include/linux/mcb.h| 1 +
 3 files changed, 3 insertions(+)

-- 
2.6.6



[PATCH v2 0/2] Add (PCI) DMA support to MCB.

2016-08-29 Thread Michael Moese
This is v2 of this patch series.
The first series had missing commit logs and named the dma_dev differently 
in include/linux/mcb.h and drivers/mcb/mcb-core.c. 

This small series of two patches enable (PCI) DMA support in MCB.

The first patch enables PCI bus mastering by default for all PCI-based MCB 
devices.

The second patch adds a dma_device to the mcb_device for all devices as a 
shortcut to mcb_device->bus->carrier.


Michael Moese (2):
  Enable PCI bus mastering by default
  Add a dma_device to mcb_device

 drivers/mcb/mcb-core.c | 1 +
 drivers/mcb/mcb-pci.c  | 1 +
 include/linux/mcb.h| 1 +
 3 files changed, 3 insertions(+)

-- 
2.6.6



[Add PCI DMA support to MCB 0/2]

2016-08-29 Thread Michael Moese
This small series of two patches enable (PCI) DMA support in MCB.

The first patch enables PCI bus mastering by default for all
PCI-based MCB devices.

The second patch adds a dma_device to the mcb_device for all devices
as a shortcut to mcb_device->bus->carrier.

Michael Moese (2):
  Enable PCI bus mastering by default
  Add a dma_device to mcb_device

 drivers/mcb/mcb-core.c | 1 +
 drivers/mcb/mcb-pci.c  | 1 +
 include/linux/mcb.h| 1 +
 3 files changed, 3 insertions(+)

--
2.6.6


[Add PCI DMA support to MCB 2/2] Add a dma_device to mcb_device

2016-08-29 Thread Michael Moese
Signed-off-by: Michael Moese <michael.mo...@men.de>
---
 drivers/mcb/mcb-core.c | 1 +
 include/linux/mcb.h| 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index 5306966..e74bfea 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -233,6 +233,7 @@ int mcb_device_register(struct mcb_bus *bus, struct 
mcb_device *dev)
dev->dev.bus = _bus_type;
dev->dev.parent = bus->dev.parent;
dev->dev.release = mcb_release_dev;
+   dev->dma_device = bus->carrier;
 
device_id = dev->id;
dev_set_name(>dev, "mcb%d-16z%03d-%d:%d:%d",
diff --git a/include/linux/mcb.h b/include/linux/mcb.h
index ee5200d..4097ac9 100644
--- a/include/linux/mcb.h
+++ b/include/linux/mcb.h
@@ -76,6 +76,7 @@ struct mcb_device {
int rev;
struct resource irq;
struct resource mem;
+   struct device *dma_dev;
 };
 
 static inline struct mcb_device *to_mcb_device(struct device *dev)
-- 
2.6.6



[Add PCI DMA support to MCB 0/2]

2016-08-29 Thread Michael Moese
This small series of two patches enable (PCI) DMA support in MCB.

The first patch enables PCI bus mastering by default for all
PCI-based MCB devices.

The second patch adds a dma_device to the mcb_device for all devices
as a shortcut to mcb_device->bus->carrier.

Michael Moese (2):
  Enable PCI bus mastering by default
  Add a dma_device to mcb_device

 drivers/mcb/mcb-core.c | 1 +
 drivers/mcb/mcb-pci.c  | 1 +
 include/linux/mcb.h| 1 +
 3 files changed, 3 insertions(+)

--
2.6.6


[Add PCI DMA support to MCB 2/2] Add a dma_device to mcb_device

2016-08-29 Thread Michael Moese
Signed-off-by: Michael Moese 
---
 drivers/mcb/mcb-core.c | 1 +
 include/linux/mcb.h| 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index 5306966..e74bfea 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -233,6 +233,7 @@ int mcb_device_register(struct mcb_bus *bus, struct 
mcb_device *dev)
dev->dev.bus = _bus_type;
dev->dev.parent = bus->dev.parent;
dev->dev.release = mcb_release_dev;
+   dev->dma_device = bus->carrier;
 
device_id = dev->id;
dev_set_name(>dev, "mcb%d-16z%03d-%d:%d:%d",
diff --git a/include/linux/mcb.h b/include/linux/mcb.h
index ee5200d..4097ac9 100644
--- a/include/linux/mcb.h
+++ b/include/linux/mcb.h
@@ -76,6 +76,7 @@ struct mcb_device {
int rev;
struct resource irq;
struct resource mem;
+   struct device *dma_dev;
 };
 
 static inline struct mcb_device *to_mcb_device(struct device *dev)
-- 
2.6.6



[Add PCI DMA support to MCB 1/2] Enable PCI bus mastering by default

2016-08-29 Thread Michael Moese
Signed-off-by: Michael Moese <michael.mo...@men.de>
---
 drivers/mcb/mcb-pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mcb/mcb-pci.c b/drivers/mcb/mcb-pci.c
index b15a034..af4d2f2 100644
--- a/drivers/mcb/mcb-pci.c
+++ b/drivers/mcb/mcb-pci.c
@@ -46,6 +46,7 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
dev_err(>dev, "Failed to enable PCI device\n");
return -ENODEV;
}
+   pci_set_master(pdev);
 
priv->mapbase = pci_resource_start(pdev, 0);
if (!priv->mapbase) {
-- 
2.6.6



[Add PCI DMA support to MCB 1/2] Enable PCI bus mastering by default

2016-08-29 Thread Michael Moese
Signed-off-by: Michael Moese 
---
 drivers/mcb/mcb-pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mcb/mcb-pci.c b/drivers/mcb/mcb-pci.c
index b15a034..af4d2f2 100644
--- a/drivers/mcb/mcb-pci.c
+++ b/drivers/mcb/mcb-pci.c
@@ -46,6 +46,7 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
dev_err(>dev, "Failed to enable PCI device\n");
return -ENODEV;
}
+   pci_set_master(pdev);
 
priv->mapbase = pci_resource_start(pdev, 0);
if (!priv->mapbase) {
-- 
2.6.6



[RFC PATCH] powerpc: add ioremap_wt

2014-02-02 Thread Michael Moese
Allow for IO memory to be mapped cacheable for performing
PCI read bursts.

Signed-off-by: Michael Moese 
---
 arch/powerpc/include/asm/io.h | 3 +++
 arch/powerpc/mm/pgtable_32.c  | 8 
 2 files changed, 11 insertions(+)

diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index 45698d5..9591fff 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -631,6 +631,8 @@ static inline void iosync(void)
  *
  * * ioremap_wc enables write combining
  *
+ * * ioremap_wc enables write thru
+ *
  * * iounmap undoes such a mapping and can be hooked
  *
  * * __ioremap_at (and the pending __iounmap_at) are low level functions to
@@ -652,6 +654,7 @@ extern void __iomem *ioremap(phys_addr_t address, unsigned 
long size);
 extern void __iomem *ioremap_prot(phys_addr_t address, unsigned long size,
  unsigned long flags);
 extern void __iomem *ioremap_wc(phys_addr_t address, unsigned long size);
+extern void __iomem *ioremap_wt(phys_addr_t address, unsigned long size);
 #define ioremap_nocache(addr, size)ioremap((addr), (size))
 
 extern void iounmap(volatile void __iomem *addr);
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 51f8795..9ab0a54 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -141,6 +141,14 @@ ioremap_wc(phys_addr_t addr, unsigned long size)
 EXPORT_SYMBOL(ioremap_wc);
 
 void __iomem *
+ioremap_wt(phys_addr_t addr, unsigned long size)
+{
+   return __ioremap_caller(addr, size, _PAGE_WRITETHRU,
+   __builtin_return_address(0));
+}
+EXPORT_SYMBOL(ioremap_wt);
+
+void __iomem *
 ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long flags)
 {
/* writeable implies dirty for kernel addresses */
-- 
1.8.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC PATCH] powerpc: add ioremap_wt

2014-02-02 Thread Michael Moese
Allow for IO memory to be mapped cacheable for performing
PCI read bursts.

Signed-off-by: Michael Moese michael.mo...@men.de
---
 arch/powerpc/include/asm/io.h | 3 +++
 arch/powerpc/mm/pgtable_32.c  | 8 
 2 files changed, 11 insertions(+)

diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index 45698d5..9591fff 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -631,6 +631,8 @@ static inline void iosync(void)
  *
  * * ioremap_wc enables write combining
  *
+ * * ioremap_wc enables write thru
+ *
  * * iounmap undoes such a mapping and can be hooked
  *
  * * __ioremap_at (and the pending __iounmap_at) are low level functions to
@@ -652,6 +654,7 @@ extern void __iomem *ioremap(phys_addr_t address, unsigned 
long size);
 extern void __iomem *ioremap_prot(phys_addr_t address, unsigned long size,
  unsigned long flags);
 extern void __iomem *ioremap_wc(phys_addr_t address, unsigned long size);
+extern void __iomem *ioremap_wt(phys_addr_t address, unsigned long size);
 #define ioremap_nocache(addr, size)ioremap((addr), (size))
 
 extern void iounmap(volatile void __iomem *addr);
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 51f8795..9ab0a54 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -141,6 +141,14 @@ ioremap_wc(phys_addr_t addr, unsigned long size)
 EXPORT_SYMBOL(ioremap_wc);
 
 void __iomem *
+ioremap_wt(phys_addr_t addr, unsigned long size)
+{
+   return __ioremap_caller(addr, size, _PAGE_WRITETHRU,
+   __builtin_return_address(0));
+}
+EXPORT_SYMBOL(ioremap_wt);
+
+void __iomem *
 ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long flags)
 {
/* writeable implies dirty for kernel addresses */
-- 
1.8.5.3

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/