* macio modalias & mpc52xx related patches for 2.6.22 @ 2007-05-06 15:38 Sylvain Munaut 2007-05-06 15:38 ` [PATCH 1/8] powerpc: Fix the MODALIAS generation in modpost for of devices Sylvain Munaut 0 siblings, 1 reply; 10+ messages in thread From: Sylvain Munaut @ 2007-05-06 15:38 UTC (permalink / raw) To: Paul Mackerras; +Cc: PPC dev ML Hello Paul, Here's the patch I'd like to see merged for 2.6.22 The first one fixs the remaining autoload problems that appeared with the uevent stuff. It has been tested by me, Johannes & benh. The second & third are just a clean up to avoid discrepency in the modalias generation (the same string was generated differently at several place). They work fine on my G5. The rest of the series are patch I received on the -embedded list, they've been reviewed/tested by at least either Grant or me. Sylvain ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/8] powerpc: Fix the MODALIAS generation in modpost for of devices 2007-05-06 15:38 macio modalias & mpc52xx related patches for 2.6.22 Sylvain Munaut @ 2007-05-06 15:38 ` Sylvain Munaut 2007-05-06 15:38 ` [PATCH 2/8] powerpc: export of_device_get_modalias Sylvain Munaut 2007-05-07 9:09 ` [PATCH 1/8] powerpc: Fix the MODALIAS generation in modpost for of devices Johannes Berg 0 siblings, 2 replies; 10+ messages in thread From: Sylvain Munaut @ 2007-05-06 15:38 UTC (permalink / raw) To: Paul Mackerras; +Cc: PPC dev ML, Sylvain Munaut Since the devices may have multiple (or none) compatible properties, the uevent generated internally by the kernel may have multiple "C..." entries. So the MODALIAS stored in the module must have wilcard before and after the compatible entry. Also, if the 'compatible' field is not used for matching, there will be no 'C' and that must handled as well. The previous code handled all those case incorrectly and it "mostly" worked ... but not always. Signed-off-by: Sylvain Munaut <tnt@246tNt.com> --- scripts/mod/file2alias.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index b2f73ff..4903292 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -354,11 +354,16 @@ static int do_pcmcia_entry(const char *filename, static int do_of_entry (const char *filename, struct of_device_id *of, char *alias) { + int len; char *tmp; - sprintf (alias, "of:N%sT%sC%s", + len = sprintf (alias, "of:N%sT%s", of->name[0] ? of->name : "*", - of->type[0] ? of->type : "*", - of->compatible[0] ? of->compatible : "*"); + of->type[0] ? of->type : "*"); + + if (of->compatible[0]) + sprintf (&alias[len], "%sC%s", + of->type[0] ? "*" : "", + of->compatible); /* Replace all whitespace with underscores */ for (tmp = alias; tmp && *tmp; tmp++) -- 1.5.1.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/8] powerpc: export of_device_get_modalias 2007-05-06 15:38 ` [PATCH 1/8] powerpc: Fix the MODALIAS generation in modpost for of devices Sylvain Munaut @ 2007-05-06 15:38 ` Sylvain Munaut 2007-05-06 15:38 ` [PATCH 3/8] macintosh: Use common modalias generation for macio_sysfs Sylvain Munaut 2007-05-07 9:09 ` [PATCH 1/8] powerpc: Fix the MODALIAS generation in modpost for of devices Johannes Berg 1 sibling, 1 reply; 10+ messages in thread From: Sylvain Munaut @ 2007-05-06 15:38 UTC (permalink / raw) To: Paul Mackerras; +Cc: PPC dev ML, Sylvain Munaut Apparently other parts of the kernel need to know the modalias internally (like the sysfs code in macintosh driver). To avoid consistency issues, we export this code and use it everywhere it's needed rather than repeat it ... Signed-off-by: Sylvain Munaut <tnt@246tNt.com> --- arch/powerpc/kernel/of_device.c | 5 +++-- include/asm-powerpc/of_device.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/of_device.c b/arch/powerpc/kernel/of_device.c index 0c8ea76..38a0ef2 100644 --- a/arch/powerpc/kernel/of_device.c +++ b/arch/powerpc/kernel/of_device.c @@ -120,8 +120,8 @@ void of_device_unregister(struct of_device *ofdev) } -static ssize_t of_device_get_modalias(struct of_device *ofdev, - char *str, ssize_t len) +ssize_t of_device_get_modalias(struct of_device *ofdev, + char *str, ssize_t len) { const char *compat; int cplen, i; @@ -239,3 +239,4 @@ EXPORT_SYMBOL(of_dev_get); EXPORT_SYMBOL(of_dev_put); EXPORT_SYMBOL(of_release_dev); EXPORT_SYMBOL(of_device_uevent); +EXPORT_SYMBOL(of_device_get_modalias); diff --git a/include/asm-powerpc/of_device.h b/include/asm-powerpc/of_device.h index 4f1aabe..e9af49e 100644 --- a/include/asm-powerpc/of_device.h +++ b/include/asm-powerpc/of_device.h @@ -32,6 +32,8 @@ extern int of_device_register(struct of_device *ofdev); extern void of_device_unregister(struct of_device *ofdev); extern void of_release_dev(struct device *dev); +extern ssize_t of_device_get_modalias(struct of_device *ofdev, + char *str, ssize_t len); extern int of_device_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size); -- 1.5.1.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/8] macintosh: Use common modalias generation for macio_sysfs 2007-05-06 15:38 ` [PATCH 2/8] powerpc: export of_device_get_modalias Sylvain Munaut @ 2007-05-06 15:38 ` Sylvain Munaut 2007-05-06 15:38 ` [PATCH 4/8] powerpc: lite5200(b) dts fixes Sylvain Munaut 0 siblings, 1 reply; 10+ messages in thread From: Sylvain Munaut @ 2007-05-06 15:38 UTC (permalink / raw) To: Paul Mackerras; +Cc: PPC dev ML, Sylvain Munaut There is now a common function to generate the modalias string, so use it. We just need to add the \n at the end. Signed-off-by: Sylvain Munaut <tnt@246tNt.com> --- drivers/macintosh/macio_sysfs.c | 29 ++++++++--------------------- 1 files changed, 8 insertions(+), 21 deletions(-) diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c index cc82679..d8fadc4 100644 --- a/drivers/macintosh/macio_sysfs.c +++ b/drivers/macintosh/macio_sysfs.c @@ -40,29 +40,16 @@ compatible_show (struct device *dev, struct device_attribute *attr, char *buf) static ssize_t modalias_show (struct device *dev, struct device_attribute *attr, char *buf) -{ - struct of_device *of; - const char *compat; - int cplen; - int length; +{ + struct of_device *ofdev = to_of_device(dev); + int len; - of = &to_macio_device (dev)->ofdev; - compat = of_get_property(of->node, "compatible", &cplen); - if (!compat) compat = "", cplen = 1; - length = sprintf (buf, "of:N%sT%s", of->node->name, of->node->type); - buf += length; - while (cplen > 0) { - int l; - l = sprintf (buf, "C%s", compat); - length += l; - buf += l; - l = strlen (compat) + 1; - compat += l; - cplen -= l; - } - length += sprintf(buf, "\n"); + len = of_device_get_modalias(ofdev, buf, PAGE_SIZE); - return length; + buf[len] = '\n'; + buf[len+1] = 0; + + return len+1; } macio_config_of_attr (name, "%s\n"); -- 1.5.1.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/8] powerpc: lite5200(b) dts fixes 2007-05-06 15:38 ` [PATCH 3/8] macintosh: Use common modalias generation for macio_sysfs Sylvain Munaut @ 2007-05-06 15:38 ` Sylvain Munaut 2007-05-06 15:38 ` [PATCH 5/8] powerpc: lite5200(b) support for i2c Sylvain Munaut 0 siblings, 1 reply; 10+ messages in thread From: Sylvain Munaut @ 2007-05-06 15:38 UTC (permalink / raw) To: Paul Mackerras; +Cc: PPC dev ML, Sylvain Munaut, Domen Puncer From: Domen Puncer <domen.puncer@telargo.com> Three trivial DTS fixes: -Mark Lite5200(b) boards as "mpc5200" compatible. On efika the firmware already does that. -Fix mscan interrupt. -Fix wakeup GPIO address. Signed-off-by: Domen Puncer <domen.puncer@telargo.com> Signed-off-by: Sylvain Munaut <tnt@246tNt.com> --- arch/powerpc/boot/dts/lite5200.dts | 5 +++-- arch/powerpc/boot/dts/lite5200b.dts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/boot/dts/lite5200.dts b/arch/powerpc/boot/dts/lite5200.dts index ba54c6b..6e2650d 100644 --- a/arch/powerpc/boot/dts/lite5200.dts +++ b/arch/powerpc/boot/dts/lite5200.dts @@ -48,6 +48,7 @@ soc5200@f0000000 { model = "fsl,mpc5200"; + compatible = "mpc5200"; revision = "" // from bootloader #interrupt-cells = <3>; device_type = "soc"; @@ -166,7 +167,7 @@ device_type = "mscan"; compatible = "mpc5200-mscan"; cell-index = <1>; - interrupts = <1 12 0>; + interrupts = <2 12 0>; interrupt-parent = <500>; reg = <980 80>; }; @@ -178,7 +179,7 @@ interrupt-parent = <500>; }; - gpio-wkup@b00 { + gpio-wkup@c00 { compatible = "mpc5200-gpio-wkup"; reg = <c00 40>; interrupts = <1 8 0 0 3 0>; diff --git a/arch/powerpc/boot/dts/lite5200b.dts b/arch/powerpc/boot/dts/lite5200b.dts index 2e00308..5ba8100 100644 --- a/arch/powerpc/boot/dts/lite5200b.dts +++ b/arch/powerpc/boot/dts/lite5200b.dts @@ -48,6 +48,7 @@ soc5200@f0000000 { model = "fsl,mpc5200b"; + compatible = "mpc5200"; revision = ""; // from bootloader #interrupt-cells = <3>; device_type = "soc"; @@ -166,7 +167,7 @@ device_type = "mscan"; compatible = "mpc5200b-mscan\0mpc5200-mscan"; cell-index = <1>; - interrupts = <1 12 0>; + interrupts = <2 12 0>; interrupt-parent = <500>; reg = <980 80>; }; @@ -178,7 +179,7 @@ interrupt-parent = <500>; }; - gpio-wkup@b00 { + gpio-wkup@c00 { compatible = "mpc5200b-gpio-wkup\0mpc5200-gpio-wkup"; reg = <c00 40>; interrupts = <1 8 0 0 3 0>; -- 1.5.1.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/8] powerpc: lite5200(b) support for i2c 2007-05-06 15:38 ` [PATCH 4/8] powerpc: lite5200(b) dts fixes Sylvain Munaut @ 2007-05-06 15:38 ` Sylvain Munaut 2007-05-06 15:38 ` [PATCH 6/8] powerpc: Set efika's device_type to "soc" Sylvain Munaut 0 siblings, 1 reply; 10+ messages in thread From: Sylvain Munaut @ 2007-05-06 15:38 UTC (permalink / raw) To: Paul Mackerras; +Cc: PPC dev ML, Sylvain Munaut, Domen Puncer From: Domen Puncer <domen.puncer@telargo.com> Add fsl-i2c to mpc5200 i2c node in device tree, and enable FSL_SOC. Tested to work with built-in eeprom on lite5200b. Signed-off-by: Domen Puncer <domen.puncer@telargo.com> Signed-off-by: Sylvain Munaut <tnt@246tNt.com> --- arch/powerpc/boot/dts/lite5200.dts | 6 ++++-- arch/powerpc/boot/dts/lite5200b.dts | 6 ++++-- arch/powerpc/platforms/52xx/Kconfig | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/boot/dts/lite5200.dts b/arch/powerpc/boot/dts/lite5200.dts index 6e2650d..e13ac6e 100644 --- a/arch/powerpc/boot/dts/lite5200.dts +++ b/arch/powerpc/boot/dts/lite5200.dts @@ -318,20 +318,22 @@ i2c@3d00 { device_type = "i2c"; - compatible = "mpc5200-i2c"; + compatible = "mpc5200-i2c\0fsl-i2c"; cell-index = <0>; reg = <3d00 40>; interrupts = <2 f 0>; interrupt-parent = <500>; + fsl5200-clocking; }; i2c@3d40 { device_type = "i2c"; - compatible = "mpc5200-i2c"; + compatible = "mpc5200-i2c\0fsl-i2c"; cell-index = <1>; reg = <3d40 40>; interrupts = <2 10 0>; interrupt-parent = <500>; + fsl5200-clocking; }; sram@8000 { device_type = "sram"; diff --git a/arch/powerpc/boot/dts/lite5200b.dts b/arch/powerpc/boot/dts/lite5200b.dts index 5ba8100..00211b3 100644 --- a/arch/powerpc/boot/dts/lite5200b.dts +++ b/arch/powerpc/boot/dts/lite5200b.dts @@ -323,20 +323,22 @@ i2c@3d00 { device_type = "i2c"; - compatible = "mpc5200b-i2c\0mpc5200-i2c"; + compatible = "mpc5200b-i2c\0mpc5200-i2c\0fsl-i2c"; cell-index = <0>; reg = <3d00 40>; interrupts = <2 f 0>; interrupt-parent = <500>; + fsl5200-clocking; }; i2c@3d40 { device_type = "i2c"; - compatible = "mpc5200b-i2c\0mpc5200-i2c"; + compatible = "mpc5200b-i2c\0mpc5200-i2c\0fsl-i2c"; cell-index = <1>; reg = <3d40 40>; interrupts = <2 10 0>; interrupt-parent = <500>; + fsl5200-clocking; }; sram@8000 { device_type = "sram"; diff --git a/arch/powerpc/platforms/52xx/Kconfig b/arch/powerpc/platforms/52xx/Kconfig index bc4aa4a..3ffaa06 100644 --- a/arch/powerpc/platforms/52xx/Kconfig +++ b/arch/powerpc/platforms/52xx/Kconfig @@ -1,5 +1,6 @@ config PPC_MPC52xx bool + select FSL_SOC default n config PPC_MPC5200 -- 1.5.1.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/8] powerpc: Set efika's device_type to "soc" 2007-05-06 15:38 ` [PATCH 5/8] powerpc: lite5200(b) support for i2c Sylvain Munaut @ 2007-05-06 15:38 ` Sylvain Munaut 2007-05-06 15:38 ` [PATCH 7/8] serial/powerpc: Don't shutdown TX on mpc5200 serial port if it is a console Sylvain Munaut 0 siblings, 1 reply; 10+ messages in thread From: Sylvain Munaut @ 2007-05-06 15:38 UTC (permalink / raw) To: Paul Mackerras; +Cc: PPC dev ML, Sylvain Munaut, Domen Puncer From: Domen Puncer <domen.puncer@telargo.com> Device type should be "soc" (as in lite5200.dts), compatible is already set to "mpc5200". Signed-off-by: Domen Puncer <domen.puncer@telargo.com> Signed-off-by: Sylvain Munaut <tnt@246tNt.com> --- arch/powerpc/kernel/prom_init.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index e27d9d1..87efb42 100644 --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c @@ -2153,7 +2153,7 @@ static void __init fixup_device_tree_efika(void) 3,12,0, 3,13,0, 3,14,0, 3,15,0 }; struct subst_entry efika_subst_table[] = { { "/", "device_type", prop_cstr("efika") }, - { "/builtin", "compatible", prop_cstr("soc") }, + { "/builtin", "device_type", prop_cstr("soc") }, { "/builtin/ata", "compatible", prop_cstr("mpc5200b-ata\0mpc5200-ata"), }, { "/builtin/bestcomm", "compatible", prop_cstr("mpc5200b-bestcomm\0mpc5200-bestcomm") }, { "/builtin/bestcomm", "interrupts", prop_bcomm_irq, sizeof(prop_bcomm_irq) }, -- 1.5.1.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 7/8] serial/powerpc: Don't shutdown TX on mpc5200 serial port if it is a console 2007-05-06 15:38 ` [PATCH 6/8] powerpc: Set efika's device_type to "soc" Sylvain Munaut @ 2007-05-06 15:38 ` Sylvain Munaut 2007-05-06 15:38 ` [PATCH 8/8] powerpc: mpc52xx suspend to deep-sleep Sylvain Munaut 0 siblings, 1 reply; 10+ messages in thread From: Sylvain Munaut @ 2007-05-06 15:38 UTC (permalink / raw) To: Paul Mackerras; +Cc: PPC dev ML, Sylvain Munaut From: Grant Likely <grant.likely@secretlab.ca> If the serial port gets shut down, then console output stalls. 9 out of 10 kernel hackers agree, this is a bad thing. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Sylvain Munaut <tnt@246tNt.com> --- drivers/serial/mpc52xx_uart.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index f8c1761..35f8b86 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c @@ -257,9 +257,10 @@ mpc52xx_uart_shutdown(struct uart_port *port) { struct mpc52xx_psc __iomem *psc = PSC(port); - /* Shut down the port, interrupt and all */ + /* Shut down the port. Leave TX active if on a console port */ out_8(&psc->command,MPC52xx_PSC_RST_RX); - out_8(&psc->command,MPC52xx_PSC_RST_TX); + if (!uart_console(port)) + out_8(&psc->command,MPC52xx_PSC_RST_TX); port->read_status_mask = 0; out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask); -- 1.5.1.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 8/8] powerpc: mpc52xx suspend to deep-sleep 2007-05-06 15:38 ` [PATCH 7/8] serial/powerpc: Don't shutdown TX on mpc5200 serial port if it is a console Sylvain Munaut @ 2007-05-06 15:38 ` Sylvain Munaut 0 siblings, 0 replies; 10+ messages in thread From: Sylvain Munaut @ 2007-05-06 15:38 UTC (permalink / raw) To: Paul Mackerras; +Cc: PPC dev ML, Sylvain Munaut, Domen Puncer From: Domen Puncer <domen.puncer@telargo.com> Implement deep-sleep on MPC52xx. SDRAM is put into self-refresh with help of SRAM code (alternatives would be code in FLASH, I-cache). Interrupt code must also not be in SDRAM, so put it in I-cache. MPC52xx core is static, so contents will remain intact even with clocks turned off. Signed-off-by: Domen Puncer <domen.puncer@telargo.com> Acked-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Sylvain Munaut <tnt@246tNt.com> --- arch/powerpc/platforms/52xx/Makefile | 2 + arch/powerpc/platforms/52xx/efika.c | 15 ++ arch/powerpc/platforms/52xx/lite5200.c | 28 ++++ arch/powerpc/platforms/52xx/mpc52xx_pm.c | 191 +++++++++++++++++++++++++++ arch/powerpc/platforms/52xx/mpc52xx_sleep.S | 154 +++++++++++++++++++++ include/asm-powerpc/mpc52xx.h | 11 ++ 6 files changed, 401 insertions(+), 0 deletions(-) create mode 100644 arch/powerpc/platforms/52xx/mpc52xx_pm.c create mode 100644 arch/powerpc/platforms/52xx/mpc52xx_sleep.S diff --git a/arch/powerpc/platforms/52xx/Makefile b/arch/powerpc/platforms/52xx/Makefile index 07cdbca..b91e39c 100644 --- a/arch/powerpc/platforms/52xx/Makefile +++ b/arch/powerpc/platforms/52xx/Makefile @@ -8,3 +8,5 @@ endif obj-$(CONFIG_PPC_EFIKA) += efika.o obj-$(CONFIG_PPC_LITE5200) += lite5200.o + +obj-$(CONFIG_PM) += mpc52xx_sleep.o mpc52xx_pm.o diff --git a/arch/powerpc/platforms/52xx/efika.c b/arch/powerpc/platforms/52xx/efika.c index a6bba97..f591a9f 100644 --- a/arch/powerpc/platforms/52xx/efika.c +++ b/arch/powerpc/platforms/52xx/efika.c @@ -184,6 +184,16 @@ static void efika_show_cpuinfo(struct seq_file *m) of_node_put(root); } +#ifdef CONFIG_PM +static void efika_suspend_prepare(void __iomem *mbar) +{ + u8 pin = 4; /* GPIO_WKUP_4 (GPIO_PSC6_0 - IRDA_RX) */ + u8 level = 1; /* wakeup on high level */ + /* IOW. to wake it up, short pins 1 and 3 on IRDA connector */ + mpc52xx_set_wakeup_gpio(pin, level); +} +#endif + static void __init efika_setup_arch(void) { rtas_initialize(); @@ -199,6 +209,11 @@ static void __init efika_setup_arch(void) efika_pcisetup(); +#ifdef CONFIG_PM + mpc52xx_suspend.board_suspend_prepare = efika_suspend_prepare; + mpc52xx_pm_init(); +#endif + if (ppc_md.progress) ppc_md.progress("Linux/PPC " UTS_RELEASE " running on Efika ;-)\n", 0x0); } diff --git a/arch/powerpc/platforms/52xx/lite5200.c b/arch/powerpc/platforms/52xx/lite5200.c index 8e2646a..1cfc00d 100644 --- a/arch/powerpc/platforms/52xx/lite5200.c +++ b/arch/powerpc/platforms/52xx/lite5200.c @@ -85,6 +85,28 @@ error: iounmap(gpio); } +#ifdef CONFIG_PM +static u32 descr_a; +static void lite5200_suspend_prepare(void __iomem *mbar) +{ + u8 pin = 1; /* GPIO_WKUP_1 (GPIO_PSC2_4) */ + u8 level = 0; /* wakeup on low level */ + mpc52xx_set_wakeup_gpio(pin, level); + + /* + * power down usb port + * this needs to be called before of-ohci suspend code + */ + descr_a = in_be32(mbar + 0x1048); + out_be32(mbar + 0x1048, (descr_a & ~0x200) | 0x100); +} + +static void lite5200_resume_finish(void __iomem *mbar) +{ + out_be32(mbar + 0x1048, descr_a); +} +#endif + static void __init lite5200_setup_arch(void) { struct device_node *np; @@ -107,6 +129,12 @@ static void __init lite5200_setup_arch(void) mpc52xx_setup_cpu(); /* Generic */ lite5200_setup_cpu(); /* Platorm specific */ +#ifdef CONFIG_PM + mpc52xx_suspend.board_suspend_prepare = lite5200_suspend_prepare; + mpc52xx_suspend.board_resume_finish = lite5200_resume_finish; + mpc52xx_pm_init(); +#endif + #ifdef CONFIG_PCI np = of_find_node_by_type(NULL, "pci"); if (np) { diff --git a/arch/powerpc/platforms/52xx/mpc52xx_pm.c b/arch/powerpc/platforms/52xx/mpc52xx_pm.c new file mode 100644 index 0000000..fd40044 --- /dev/null +++ b/arch/powerpc/platforms/52xx/mpc52xx_pm.c @@ -0,0 +1,191 @@ +#include <linux/init.h> +#include <linux/pm.h> +#include <linux/io.h> +#include <asm/time.h> +#include <asm/cacheflush.h> +#include <asm/mpc52xx.h> + +#include "mpc52xx_pic.h" + + +/* these are defined in mpc52xx_sleep.S, and only used here */ +extern void mpc52xx_deep_sleep(void *sram, void *sdram_regs, + struct mpc52xx_cdm *, struct mpc52xx_intr *); +extern void mpc52xx_ds_sram(void); +extern const long mpc52xx_ds_sram_size; +extern void mpc52xx_ds_cached(void); +extern const long mpc52xx_ds_cached_size; + +static void __iomem *mbar; +static void __iomem *sdram; +static struct mpc52xx_cdm __iomem *cdm; +static struct mpc52xx_intr __iomem *intr; +static struct mpc52xx_gpio_wkup __iomem *gpiow; +static void *sram; +static int sram_size; + +struct mpc52xx_suspend mpc52xx_suspend; + +static int mpc52xx_pm_valid(suspend_state_t state) +{ + switch (state) { + case PM_SUSPEND_STANDBY: + return 1; + default: + return 0; + } +} + +int mpc52xx_set_wakeup_gpio(u8 pin, u8 level) +{ + u16 tmp; + + /* enable gpio */ + out_8(&gpiow->wkup_gpioe, in_8(&gpiow->wkup_gpioe) | (1 << pin)); + /* set as input */ + out_8(&gpiow->wkup_ddr, in_8(&gpiow->wkup_ddr) & ~(1 << pin)); + /* enable deep sleep interrupt */ + out_8(&gpiow->wkup_inten, in_8(&gpiow->wkup_inten) | (1 << pin)); + /* low/high level creates wakeup interrupt */ + tmp = in_be16(&gpiow->wkup_itype); + tmp &= ~(0x3 << (pin * 2)); + tmp |= (!level + 1) << (pin * 2); + out_be16(&gpiow->wkup_itype, tmp); + /* master enable */ + out_8(&gpiow->wkup_maste, 1); + + return 0; +} + +int mpc52xx_pm_prepare(suspend_state_t state) +{ + if (state != PM_SUSPEND_STANDBY) + return -EINVAL; + + /* map the whole register space */ + mbar = mpc52xx_find_and_map("mpc5200"); + if (!mbar) { + printk(KERN_ERR "%s:%i Error mapping registers\n", __func__, __LINE__); + return -ENOSYS; + } + /* these offsets are from mpc5200 users manual */ + sdram = mbar + 0x100; + cdm = mbar + 0x200; + intr = mbar + 0x500; + gpiow = mbar + 0xc00; + sram = mbar + 0x8000; /* Those will be handled by the */ + sram_size = 0x4000; /* bestcomm driver soon */ + + /* call board suspend code, if applicable */ + if (mpc52xx_suspend.board_suspend_prepare) + mpc52xx_suspend.board_suspend_prepare(mbar); + else { + printk(KERN_ALERT "%s: %i don't know how to wake up the board\n", + __func__, __LINE__); + goto out_unmap; + } + + return 0; + + out_unmap: + iounmap(mbar); + return -ENOSYS; +} + + +char saved_sram[0x4000]; + +int mpc52xx_pm_enter(suspend_state_t state) +{ + u32 clk_enables; + u32 msr, hid0; + u32 intr_main_mask; + void __iomem * irq_0x500 = (void *)CONFIG_KERNEL_START + 0x500; + unsigned long irq_0x500_stop = (unsigned long)irq_0x500 + mpc52xx_ds_cached_size; + char saved_0x500[mpc52xx_ds_cached_size]; + + /* disable all interrupts in PIC */ + intr_main_mask = in_be32(&intr->main_mask); + out_be32(&intr->main_mask, intr_main_mask | 0x1ffff); + + /* don't let DEC expire any time soon */ + mtspr(SPRN_DEC, 0x7fffffff); + + /* save SRAM */ + memcpy(saved_sram, sram, sram_size); + + /* copy low level suspend code to sram */ + memcpy(sram, mpc52xx_ds_sram, mpc52xx_ds_sram_size); + + out_8(&cdm->ccs_sleep_enable, 1); + out_8(&cdm->osc_sleep_enable, 1); + out_8(&cdm->ccs_qreq_test, 1); + + /* disable all but SDRAM and bestcomm (SRAM) clocks */ + clk_enables = in_be32(&cdm->clk_enables); + out_be32(&cdm->clk_enables, clk_enables & 0x00088000); + + /* disable power management */ + msr = mfmsr(); + mtmsr(msr & ~MSR_POW); + + /* enable sleep mode, disable others */ + hid0 = mfspr(SPRN_HID0); + mtspr(SPRN_HID0, (hid0 & ~(HID0_DOZE | HID0_NAP | HID0_DPM)) | HID0_SLEEP); + + /* save original, copy our irq handler, flush from dcache and invalidate icache */ + memcpy(saved_0x500, irq_0x500, mpc52xx_ds_cached_size); + memcpy(irq_0x500, mpc52xx_ds_cached, mpc52xx_ds_cached_size); + flush_icache_range((unsigned long)irq_0x500, irq_0x500_stop); + + /* call low-level sleep code */ + mpc52xx_deep_sleep(sram, sdram, cdm, intr); + + /* restore original irq handler */ + memcpy(irq_0x500, saved_0x500, mpc52xx_ds_cached_size); + flush_icache_range((unsigned long)irq_0x500, irq_0x500_stop); + + /* restore old power mode */ + mtmsr(msr & ~MSR_POW); + mtspr(SPRN_HID0, hid0); + mtmsr(msr); + + out_be32(&cdm->clk_enables, clk_enables); + out_8(&cdm->ccs_sleep_enable, 0); + out_8(&cdm->osc_sleep_enable, 0); + + /* restore SRAM */ + memcpy(sram, saved_sram, sram_size); + + /* restart jiffies */ + wakeup_decrementer(); + + /* reenable interrupts in PIC */ + out_be32(&intr->main_mask, intr_main_mask); + + return 0; +} + +int mpc52xx_pm_finish(suspend_state_t state) +{ + /* call board resume code */ + if (mpc52xx_suspend.board_resume_finish) + mpc52xx_suspend.board_resume_finish(mbar); + + iounmap(mbar); + + return 0; +} + +static struct pm_ops mpc52xx_pm_ops = { + .valid = mpc52xx_pm_valid, + .prepare = mpc52xx_pm_prepare, + .enter = mpc52xx_pm_enter, + .finish = mpc52xx_pm_finish, +}; + +int __init mpc52xx_pm_init(void) +{ + pm_set_ops(&mpc52xx_pm_ops); + return 0; +} diff --git a/arch/powerpc/platforms/52xx/mpc52xx_sleep.S b/arch/powerpc/platforms/52xx/mpc52xx_sleep.S new file mode 100644 index 0000000..4dc170b --- /dev/null +++ b/arch/powerpc/platforms/52xx/mpc52xx_sleep.S @@ -0,0 +1,154 @@ +#include <asm/reg.h> +#include <asm/ppc_asm.h> +#include <asm/processor.h> + + +.text + +_GLOBAL(mpc52xx_deep_sleep) +mpc52xx_deep_sleep: /* args r3-r6: SRAM, SDRAM regs, CDM regs, INTR regs */ + + /* enable interrupts */ + mfmsr r7 + ori r7, r7, 0x8000 /* EE */ + mtmsr r7 + sync; isync; + + li r10, 0 /* flag that irq handler sets */ + + /* enable tmr7 (or any other) interrupt */ + lwz r8, 0x14(r6) /* intr->main_mask */ + ori r8, r8, 0x1 + xori r8, r8, 0x1 + stw r8, 0x14(r6) + sync + + /* emulate tmr7 interrupt */ + li r8, 0x1 + stw r8, 0x40(r6) /* intr->main_emulate */ + sync + + /* wait for it to happen */ +1: + cmpi cr0, r10, 1 + bne cr0, 1b + + /* lock icache */ + mfspr r10, SPRN_HID0 + ori r10, r10, 0x2000 + sync; isync; + mtspr SPRN_HID0, r10 + sync; isync; + + + mflr r9 /* save LR */ + + /* jump to sram */ + mtlr r3 + blrl + + mtlr r9 /* restore LR */ + + /* unlock icache */ + mfspr r10, SPRN_HID0 + ori r10, r10, 0x2000 + xori r10, r10, 0x2000 + sync; isync; + mtspr SPRN_HID0, r10 + sync; isync; + + + /* return to C code */ + blr + + +_GLOBAL(mpc52xx_ds_sram) +mpc52xx_ds_sram: + /* put SDRAM into self-refresh */ + lwz r8, 0x4(r4) /* sdram->ctrl */ + + oris r8, r8, 0x8000 /* mode_en */ + stw r8, 0x4(r4) + sync + + ori r8, r8, 0x0002 /* soft_pre */ + stw r8, 0x4(r4) + sync + xori r8, r8, 0x0002 + + xoris r8, r8, 0x8000 /* !mode_en */ + stw r8, 0x4(r4) + sync + + oris r8, r8, 0x5000 + xoris r8, r8, 0x4000 /* ref_en !cke */ + stw r8, 0x4(r4) + sync + + /* disable SDRAM clock */ + lwz r8, 0x14(r5) /* cdm->clkenable */ + ori r8, r8, 0x0008 + xori r8, r8, 0x0008 + stw r8, 0x14(r5) + sync + + + /* put mpc5200 to sleep */ + mfmsr r10 + oris r10, r10, 0x0004 /* POW = 1 */ + sync; isync; + mtmsr r10 + sync; isync; + + + /* enable clock */ + lwz r8, 0x14(r5) + ori r8, r8, 0x0008 + stw r8, 0x14(r5) + sync + + /* get ram out of self-refresh */ + lwz r8, 0x4(r4) + oris r8, r8, 0x5000 /* cke ref_en */ + stw r8, 0x4(r4) + sync + + blr +_GLOBAL(mpc52xx_ds_sram_size) +mpc52xx_ds_sram_size: + .long $-mpc52xx_ds_sram + + +/* ### interrupt handler for wakeup from deep-sleep ### */ +_GLOBAL(mpc52xx_ds_cached) +mpc52xx_ds_cached: + mtspr SPRN_SPRG0, r7 + mtspr SPRN_SPRG1, r8 + + /* disable emulated interrupt */ + mfspr r7, 311 /* MBAR */ + addi r7, r7, 0x540 /* intr->main_emul */ + li r8, 0 + stw r8, 0(r7) + sync + dcbf 0, r7 + + /* acknowledge wakeup, so CCS releases power pown */ + mfspr r7, 311 /* MBAR */ + addi r7, r7, 0x524 /* intr->enc_status */ + lwz r8, 0(r7) + ori r8, r8, 0x0400 + stw r8, 0(r7) + sync + dcbf 0, r7 + + /* flag - we handled the interrupt */ + li r10, 1 + + mfspr r8, SPRN_SPRG1 + mfspr r7, SPRN_SPRG0 + + rfi +_GLOBAL(mpc52xx_ds_cached_size) +mpc52xx_ds_cached_size: + .long $-mpc52xx_ds_cached diff --git a/include/asm-powerpc/mpc52xx.h b/include/asm-powerpc/mpc52xx.h index 7afd5bf..c4631f6 100644 --- a/include/asm-powerpc/mpc52xx.h +++ b/include/asm-powerpc/mpc52xx.h @@ -253,5 +253,16 @@ extern int __init mpc52xx_add_bridge(struct device_node *node); #endif /* __ASSEMBLY__ */ +#ifdef CONFIG_PM +struct mpc52xx_suspend { + void (*board_suspend_prepare)(void __iomem *mbar); + void (*board_resume_finish)(void __iomem *mbar); +}; + +extern struct mpc52xx_suspend mpc52xx_suspend; +extern int __init mpc52xx_pm_init(void); +extern int mpc52xx_set_wakeup_gpio(u8 pin, u8 level); +#endif /* CONFIG_PM */ + #endif /* __ASM_POWERPC_MPC52xx_H__ */ -- 1.5.1.2 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/8] powerpc: Fix the MODALIAS generation in modpost for of devices 2007-05-06 15:38 ` [PATCH 1/8] powerpc: Fix the MODALIAS generation in modpost for of devices Sylvain Munaut 2007-05-06 15:38 ` [PATCH 2/8] powerpc: export of_device_get_modalias Sylvain Munaut @ 2007-05-07 9:09 ` Johannes Berg 1 sibling, 0 replies; 10+ messages in thread From: Johannes Berg @ 2007-05-07 9:09 UTC (permalink / raw) To: Sylvain Munaut; +Cc: PPC dev ML, Paul Mackerras [-- Attachment #1: Type: text/plain, Size: 487 bytes --] On Sun, 2007-05-06 at 17:38 +0200, Sylvain Munaut wrote: > Since the devices may have multiple (or none) compatible properties, > the uevent generated internally by the kernel may have multiple > "C..." entries. So the MODALIAS stored in the module must have > wilcard before and after the compatible entry. > Also, if the 'compatible' field is not used for matching, there > will be no 'C' and that must handled as well. Ack, I really need this patch for aoa now. johannes [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 190 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-05-07 9:08 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-05-06 15:38 macio modalias & mpc52xx related patches for 2.6.22 Sylvain Munaut 2007-05-06 15:38 ` [PATCH 1/8] powerpc: Fix the MODALIAS generation in modpost for of devices Sylvain Munaut 2007-05-06 15:38 ` [PATCH 2/8] powerpc: export of_device_get_modalias Sylvain Munaut 2007-05-06 15:38 ` [PATCH 3/8] macintosh: Use common modalias generation for macio_sysfs Sylvain Munaut 2007-05-06 15:38 ` [PATCH 4/8] powerpc: lite5200(b) dts fixes Sylvain Munaut 2007-05-06 15:38 ` [PATCH 5/8] powerpc: lite5200(b) support for i2c Sylvain Munaut 2007-05-06 15:38 ` [PATCH 6/8] powerpc: Set efika's device_type to "soc" Sylvain Munaut 2007-05-06 15:38 ` [PATCH 7/8] serial/powerpc: Don't shutdown TX on mpc5200 serial port if it is a console Sylvain Munaut 2007-05-06 15:38 ` [PATCH 8/8] powerpc: mpc52xx suspend to deep-sleep Sylvain Munaut 2007-05-07 9:09 ` [PATCH 1/8] powerpc: Fix the MODALIAS generation in modpost for of devices Johannes Berg
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).