From 087a4ab272780f52f6ea24b1c0e2e8dd3a220e15 Mon Sep 17 00:00:00 2001 From: Josh Cartwright Date: Tue, 11 Feb 2014 10:24:00 -0600 Subject: bus: mvebu-mbus: make use of of_find_matching_node_and_match Instead of the of_find_matching_node()/of_match_node() pair, which requires two iterations through the match table, make use of of_find_matching_node_and_match(), which only iterates through the table once. Signed-off-by: Josh Cartwright Signed-off-by: Jason Cooper --- drivers/bus/mvebu-mbus.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c index 725c46162bbd..31f2c805d3e5 100644 --- a/drivers/bus/mvebu-mbus.c +++ b/drivers/bus/mvebu-mbus.c @@ -890,13 +890,12 @@ int __init mvebu_mbus_dt_init(void) const __be32 *prop; int ret; - np = of_find_matching_node(NULL, of_mvebu_mbus_ids); + np = of_find_matching_node_and_match(NULL, of_mvebu_mbus_ids, &of_id); if (!np) { pr_err("could not find a matching SoC family\n"); return -ENODEV; } - of_id = of_match_node(of_mvebu_mbus_ids, np); mbus_state.soc = of_id->data; prop = of_get_property(np, "controller", NULL); -- cgit v1.2.3-55-g7522 From 00b28184b1f148a60a08ddc2efd220ec4da32726 Mon Sep 17 00:00:00 2001 From: Fengguang Wu Date: Tue, 18 Feb 2014 18:00:21 +0000 Subject: rtc: isl12057: use PTR_ERR_OR_ZERO to fix coccinelle warnings drivers/rtc/rtc-isl12057.c:278:1-3: WARNING: PTR_RET can be used Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR Generated by: coccinelle/api/ptr_ret.cocci CC: Arnaud Ebalard CC: Jason Cooper Signed-off-by: Fengguang Wu Signed-off-by: Jason Cooper --- drivers/rtc/rtc-isl12057.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/rtc/rtc-isl12057.c b/drivers/rtc/rtc-isl12057.c index 7854a656628f..835b425549bd 100644 --- a/drivers/rtc/rtc-isl12057.c +++ b/drivers/rtc/rtc-isl12057.c @@ -275,10 +275,7 @@ static int isl12057_probe(struct i2c_client *client, dev_set_drvdata(dev, data); rtc = devm_rtc_device_register(dev, DRV_NAME, &rtc_ops, THIS_MODULE); - if (IS_ERR(rtc)) - return PTR_ERR(rtc); - - return 0; + return PTR_ERR_OR_ZERO(rtc); } #ifdef CONFIG_OF -- cgit v1.2.3-55-g7522 From e102dc7a5498439bf72ae9f6457f2e7fe09a4ae0 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Tue, 18 Feb 2014 14:26:06 +0100 Subject: rtc: mv: reset date if after year 2038 Dates after January, 19th 2038 are badly handled by userspace due to the time being stored on 32 bits. This causes issues on some Marvell platform on which the RTC is initialized by default to a date that's beyond 2038, causing a really weird behavior of the RTC. In order to avoid that, reset the date to a sane value if the RTC is beyond 2038. Signed-off-by: Thomas Petazzoni Signed-off-by: Jason Cooper --- drivers/rtc/rtc-mv.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c index d536c5962c99..d15a999363fc 100644 --- a/drivers/rtc/rtc-mv.c +++ b/drivers/rtc/rtc-mv.c @@ -222,6 +222,7 @@ static int __init mv_rtc_probe(struct platform_device *pdev) struct resource *res; struct rtc_plat_data *pdata; u32 rtc_time; + u32 rtc_date; int ret = 0; pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); @@ -257,6 +258,17 @@ static int __init mv_rtc_probe(struct platform_device *pdev) } } + /* + * A date after January 19th, 2038 does not fit on 32 bits and + * will confuse the kernel and userspace. Reset to a sane date + * (January 1st, 2013) if we're after 2038. + */ + rtc_date = readl(pdata->ioaddr + RTC_DATE_REG_OFFS); + if (bcd2bin((rtc_date >> RTC_YEAR_OFFS) & 0xff) >= 38) { + dev_info(&pdev->dev, "invalid RTC date, resetting to January 1st, 2013\n"); + writel(0x130101, pdata->ioaddr + RTC_DATE_REG_OFFS); + } + pdata->irq = platform_get_irq(pdev, 0); platform_set_drvdata(pdev, pdata); -- cgit v1.2.3-55-g7522 From ff1f0018cf66080d8e6f59791e552615648a033a Mon Sep 17 00:00:00 2001 From: Andrew Lunn Date: Sat, 22 Feb 2014 20:15:00 +0100 Subject: drivers: Enable building of Kirkwood drivers for mach-mvebu With the move of kirkwood into mach-mvebu, drivers Kconfig need tweeking to allow the kirkwood specific drivers to be built. Signed-off-by: Andrew Lunn Acked-by: Arnd Bergmann Acked-by: Mark Brown Acked-by: Kishon Vijay Abraham I Acked-by: Daniel Lezcano Acked-by: Viresh Kumar Tested-by: Jason Gunthorpe Cc: Viresh Kumar Cc: Rafael J. Wysocki Cc: Richard Purdie Cc: Bryan Wu Cc: Zhang Rui Cc: Eduardo Valentin Signed-off-by: Jason Cooper --- drivers/cpufreq/Kconfig.arm | 2 +- drivers/cpuidle/Kconfig.arm | 2 +- drivers/leds/Kconfig | 4 ++-- drivers/phy/Kconfig | 2 +- drivers/thermal/Kconfig | 2 +- sound/soc/kirkwood/Kconfig | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm index 31297499a60a..077db3aa985b 100644 --- a/drivers/cpufreq/Kconfig.arm +++ b/drivers/cpufreq/Kconfig.arm @@ -113,7 +113,7 @@ config ARM_INTEGRATOR If in doubt, say Y. config ARM_KIRKWOOD_CPUFREQ - def_bool ARCH_KIRKWOOD && OF + def_bool MACH_KIRKWOOD help This adds the CPUFreq driver for Marvell Kirkwood SoCs. diff --git a/drivers/cpuidle/Kconfig.arm b/drivers/cpuidle/Kconfig.arm index d988948a89a0..97ccc31dbdd8 100644 --- a/drivers/cpuidle/Kconfig.arm +++ b/drivers/cpuidle/Kconfig.arm @@ -22,7 +22,7 @@ config ARM_HIGHBANK_CPUIDLE config ARM_KIRKWOOD_CPUIDLE bool "CPU Idle Driver for Marvell Kirkwood SoCs" - depends on ARCH_KIRKWOOD + depends on ARCH_KIRKWOOD || MACH_KIRKWOOD help This adds the CPU Idle driver for Marvell Kirkwood SoCs. diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 72156c123033..44c358ecf5a1 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -421,7 +421,7 @@ config LEDS_MC13783 config LEDS_NS2 tristate "LED support for Network Space v2 GPIO LEDs" depends on LEDS_CLASS - depends on ARCH_KIRKWOOD + depends on ARCH_KIRKWOOD || MACH_KIRKWOOD default y help This option enable support for the dual-GPIO LED found on the @@ -431,7 +431,7 @@ config LEDS_NS2 config LEDS_NETXBIG tristate "LED support for Big Network series LEDs" depends on LEDS_CLASS - depends on ARCH_KIRKWOOD + depends on ARCH_KIRKWOOD || MACH_KIRKWOOD default y help This option enable support for LEDs found on the LaCie 2Big diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index afa2354f6600..5e6b33f9c294 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -24,7 +24,7 @@ config PHY_EXYNOS_MIPI_VIDEO config PHY_MVEBU_SATA def_bool y - depends on ARCH_KIRKWOOD || ARCH_DOVE + depends on ARCH_KIRKWOOD || ARCH_DOVE || MACH_KIRKWOOD depends on OF select GENERIC_PHY diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index 35c066489a19..1bc9cbc4f1b8 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -142,7 +142,7 @@ config RCAR_THERMAL config KIRKWOOD_THERMAL tristate "Temperature sensor on Marvell Kirkwood SoCs" - depends on ARCH_KIRKWOOD + depends on ARCH_KIRKWOOD || MACH_KIRKWOOD depends on OF help Support for the Kirkwood thermal sensor driver into the Linux thermal diff --git a/sound/soc/kirkwood/Kconfig b/sound/soc/kirkwood/Kconfig index 78ed4a42ad21..106e2e22fed2 100644 --- a/sound/soc/kirkwood/Kconfig +++ b/sound/soc/kirkwood/Kconfig @@ -1,6 +1,6 @@ config SND_KIRKWOOD_SOC tristate "SoC Audio for the Marvell Kirkwood and Dove chips" - depends on ARCH_KIRKWOOD || ARCH_DOVE || COMPILE_TEST + depends on ARCH_KIRKWOOD || ARCH_DOVE || MACH_KIRKWOOD || COMPILE_TEST help Say Y or M if you want to add support for codecs attached to the Kirkwood I2S interface. You will also need to select the -- cgit v1.2.3-55-g7522 From 200c0a3e404beab02be83e5cbf111d26b9f6ce22 Mon Sep 17 00:00:00 2001 From: Andrew Lunn Date: Thu, 20 Feb 2014 06:02:35 +1000 Subject: Power: Reset: Generalize qnap-poweroff to work on Synology devices. The Synology NAS devices use a very similar mechanism to QNAP NAS devices to power off. Both send a single charactor command to a PIC, over the second serial port. However the baud rate and the command differ. Generalize the driver to support this. Signed-off-by: Ben Peddell Signed-off-by: Andrew Lunn Acked-by: Jason Cooper Cc: Anton Vorontsov Cc: Dmitry Eremin-Solenikov Cc: David Woodhouse Signed-off-by: Jason Cooper --- .../bindings/power_supply/qnap-poweroff.txt | 5 ++- drivers/power/reset/qnap-poweroff.c | 49 ++++++++++++++++------ 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt b/Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt index 0347d8350d94..af25e77c0e0c 100644 --- a/Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt +++ b/Documentation/devicetree/bindings/power_supply/qnap-poweroff.txt @@ -6,8 +6,11 @@ Orion5x SoCs. Sending the character 'A', at 19200 baud, tells the microcontroller to turn the power off. This driver adds a handler to pm_power_off which is called to turn the power off. +Synology NAS devices use a similar scheme, but a different baud rate, +9600, and a different character, '1'. + Required Properties: -- compatible: Should be "qnap,power-off" +- compatible: Should be "qnap,power-off" or "synology,power-off" - reg: Address and length of the register set for UART1 - clocks: tclk clock diff --git a/drivers/power/reset/qnap-poweroff.c b/drivers/power/reset/qnap-poweroff.c index 37f56f7ee926..a75db7f8a92f 100644 --- a/drivers/power/reset/qnap-poweroff.c +++ b/drivers/power/reset/qnap-poweroff.c @@ -1,5 +1,5 @@ /* - * QNAP Turbo NAS Board power off + * QNAP Turbo NAS Board power off. Can also be used on Synology devices. * * Copyright (C) 2012 Andrew Lunn * @@ -25,17 +25,43 @@ #define UART1_REG(x) (base + ((UART_##x) << 2)) +struct power_off_cfg { + u32 baud; + char cmd; +}; + +static const struct power_off_cfg qnap_power_off_cfg = { + .baud = 19200, + .cmd = 'A', +}; + +static const struct power_off_cfg synology_power_off_cfg = { + .baud = 9600, + .cmd = '1', +}; + +static const struct of_device_id qnap_power_off_of_match_table[] = { + { .compatible = "qnap,power-off", + .data = &qnap_power_off_cfg, + }, + { .compatible = "synology,power-off", + .data = &synology_power_off_cfg, + }, + {} +}; +MODULE_DEVICE_TABLE(of, qnap_power_off_of_match_table); + static void __iomem *base; static unsigned long tclk; +static const struct power_off_cfg *cfg; static void qnap_power_off(void) { - /* 19200 baud divisor */ - const unsigned divisor = ((tclk + (8 * 19200)) / (16 * 19200)); + const unsigned divisor = ((tclk + (8 * cfg->baud)) / (16 * cfg->baud)); pr_err("%s: triggering power-off...\n", __func__); - /* hijack UART1 and reset into sane state (19200,8n1) */ + /* hijack UART1 and reset into sane state */ writel(0x83, UART1_REG(LCR)); writel(divisor & 0xff, UART1_REG(DLL)); writel((divisor >> 8) & 0xff, UART1_REG(DLM)); @@ -44,16 +70,21 @@ static void qnap_power_off(void) writel(0x00, UART1_REG(FCR)); writel(0x00, UART1_REG(MCR)); - /* send the power-off command 'A' to PIC */ - writel('A', UART1_REG(TX)); + /* send the power-off command to PIC */ + writel(cfg->cmd, UART1_REG(TX)); } static int qnap_power_off_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; struct resource *res; struct clk *clk; char symname[KSYM_NAME_LEN]; + const struct of_device_id *match = + of_match_node(qnap_power_off_of_match_table, np); + cfg = match->data; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Missing resource"); @@ -94,12 +125,6 @@ static int qnap_power_off_remove(struct platform_device *pdev) return 0; } -static const struct of_device_id qnap_power_off_of_match_table[] = { - { .compatible = "qnap,power-off", }, - {} -}; -MODULE_DEVICE_TABLE(of, qnap_power_off_of_match_table); - static struct platform_driver qnap_power_off_driver = { .probe = qnap_power_off_probe, .remove = qnap_power_off_remove, -- cgit v1.2.3-55-g7522