Skip to content

Commit

Permalink
Merge tag 'mvebu-drivers-3.15-2' of git://git.infradead.org/linux-mve…
Browse files Browse the repository at this point in the history
…bu into next/drivers

Merge "mvebu drivers for v3.15" from Jason Cooper:

pull request #1:

 - mvebu mbus
    - use of_find_matching_node_and_match

 - rtc
    - use PTR_ERR_OR_ZERO in isl12057
    - work around issue in mv where date returned is 2038

 - kirkwood -> mach-mvebu
    - various Kconfig oneliners to allow building kirkwood in -mvebu/

pull request #2:

 - reset
    - re-use qnap-poweroff driver for Synology NASs

* tag 'mvebu-drivers-3.15-2' of git://git.infradead.org/linux-mvebu:
  Power: Reset: Generalize qnap-poweroff to work on Synology devices.
  drivers: Enable building of Kirkwood drivers for mach-mvebu
  rtc: mv: reset date if after year 2038
  rtc: isl12057: use PTR_ERR_OR_ZERO to fix coccinelle warnings
  bus: mvebu-mbus: make use of of_find_matching_node_and_match

Signed-off-by: Arnd Bergmann <[email protected]>
  • Loading branch information
arndb committed Mar 17, 2014
2 parents de65ded + 200c0a3 commit cda88c8
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions drivers/bus/mvebu-mbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/cpufreq/Kconfig.arm
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion drivers/cpuidle/Kconfig.arm
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions drivers/leds/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion drivers/phy/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
49 changes: 37 additions & 12 deletions drivers/power/reset/qnap-poweroff.c
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
*
Expand All @@ -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));
Expand All @@ -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");
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions drivers/rtc/rtc-isl12057.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions drivers/rtc/rtc-mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/thermal/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sound/soc/kirkwood/Kconfig
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit cda88c8

Please sign in to comment.