From a8d3584a2df28827094f6338cde1303c467bc1f0 Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 3 Jan 2006 18:41:37 +0000 Subject: [ARM] Remove clk_use()/clk_unuse() It seems that clk_use() and clk_unuse() are additional complexity which isn't required anymore. Remove them from the clock framework to avoid the additional confusion which they cause, and update all ARM machine types except for OMAP. Signed-off-by: Russell King --- drivers/char/watchdog/s3c2410_wdt.c | 2 -- drivers/i2c/busses/i2c-s3c2410.c | 2 -- drivers/input/serio/ambakmi.c | 9 +-------- drivers/mmc/mmci.c | 9 +-------- drivers/mtd/nand/s3c2410.c | 2 -- drivers/serial/amba-pl011.c | 7 ------- drivers/serial/s3c2410.c | 5 ----- drivers/usb/host/ohci-s3c2410.c | 2 -- drivers/video/amba-clcd.c | 9 +-------- drivers/video/s3c2410fb.c | 3 --- 10 files changed, 3 insertions(+), 47 deletions(-) (limited to 'drivers') diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c index eb667daee19..621e8a99e73 100644 --- a/drivers/char/watchdog/s3c2410_wdt.c +++ b/drivers/char/watchdog/s3c2410_wdt.c @@ -397,7 +397,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev) return -ENOENT; } - clk_use(wdt_clock); clk_enable(wdt_clock); /* see if we can actually set the requested timer margin, and if @@ -444,7 +443,6 @@ static int s3c2410wdt_remove(struct platform_device *dev) if (wdt_clock != NULL) { clk_disable(wdt_clock); - clk_unuse(wdt_clock); clk_put(wdt_clock); wdt_clock = NULL; } diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 58cfd3111ef..2a2f86d8c2d 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -738,7 +738,6 @@ static void s3c24xx_i2c_free(struct s3c24xx_i2c *i2c) { if (i2c->clk != NULL && !IS_ERR(i2c->clk)) { clk_disable(i2c->clk); - clk_unuse(i2c->clk); clk_put(i2c->clk); i2c->clk = NULL; } @@ -778,7 +777,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk); - clk_use(i2c->clk); clk_enable(i2c->clk); /* map the registers */ diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c index 9b1ab5e7a98..d847ed51cfb 100644 --- a/drivers/input/serio/ambakmi.c +++ b/drivers/input/serio/ambakmi.c @@ -72,13 +72,9 @@ static int amba_kmi_open(struct serio *io) unsigned int divisor; int ret; - ret = clk_use(kmi->clk); - if (ret) - goto out; - ret = clk_enable(kmi->clk); if (ret) - goto clk_unuse; + goto out; divisor = clk_get_rate(kmi->clk) / 8000000 - 1; writeb(divisor, KMICLKDIV); @@ -97,8 +93,6 @@ static int amba_kmi_open(struct serio *io) clk_disable: clk_disable(kmi->clk); - clk_unuse: - clk_unuse(kmi->clk); out: return ret; } @@ -111,7 +105,6 @@ static void amba_kmi_close(struct serio *io) free_irq(kmi->irq, kmi); clk_disable(kmi->clk); - clk_unuse(kmi->clk); } static int amba_kmi_probe(struct amba_device *dev, void *id) diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c index 166c9b0ad04..31b0b6d612b 100644 --- a/drivers/mmc/mmci.c +++ b/drivers/mmc/mmci.c @@ -479,13 +479,9 @@ static int mmci_probe(struct amba_device *dev, void *id) goto host_free; } - ret = clk_use(host->clk); - if (ret) - goto clk_free; - ret = clk_enable(host->clk); if (ret) - goto clk_unuse; + goto clk_free; host->plat = plat; host->mclk = clk_get_rate(host->clk); @@ -558,8 +554,6 @@ static int mmci_probe(struct amba_device *dev, void *id) iounmap(host->base); clk_disable: clk_disable(host->clk); - clk_unuse: - clk_unuse(host->clk); clk_free: clk_put(host->clk); host_free: @@ -594,7 +588,6 @@ static int mmci_remove(struct amba_device *dev) iounmap(host->base); clk_disable(host->clk); - clk_unuse(host->clk); clk_put(host->clk); mmc_free_host(mmc); diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index d209214b131..b796a9a6b92 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c @@ -460,7 +460,6 @@ static int s3c2410_nand_remove(struct platform_device *pdev) if (info->clk != NULL && !IS_ERR(info->clk)) { clk_disable(info->clk); - clk_unuse(info->clk); clk_put(info->clk); } @@ -598,7 +597,6 @@ static int s3c24xx_nand_probe(struct platform_device *pdev, int is_s3c2440) goto exit_error; } - clk_use(info->clk); clk_enable(info->clk); /* allocate and map the resource */ diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c index d84476ee659..531b0e4f25e 100644 --- a/drivers/serial/amba-pl011.c +++ b/drivers/serial/amba-pl011.c @@ -761,10 +761,6 @@ static int pl011_probe(struct amba_device *dev, void *id) goto unmap; } - ret = clk_use(uap->clk); - if (ret) - goto putclk; - uap->port.dev = &dev->dev; uap->port.mapbase = dev->res.start; uap->port.membase = base; @@ -782,8 +778,6 @@ static int pl011_probe(struct amba_device *dev, void *id) if (ret) { amba_set_drvdata(dev, NULL); amba_ports[i] = NULL; - clk_unuse(uap->clk); - putclk: clk_put(uap->clk); unmap: iounmap(base); @@ -808,7 +802,6 @@ static int pl011_remove(struct amba_device *dev) amba_ports[i] = NULL; iounmap(uap->port.membase); - clk_unuse(uap->clk); clk_put(uap->clk); kfree(uap); return 0; diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c index 47681c4654e..eb47f5b71ae 100644 --- a/drivers/serial/s3c2410.c +++ b/drivers/serial/s3c2410.c @@ -782,11 +782,9 @@ static void s3c24xx_serial_set_termios(struct uart_port *port, if (ourport->baudclk != NULL && !IS_ERR(ourport->baudclk)) { clk_disable(ourport->baudclk); - clk_unuse(ourport->baudclk); ourport->baudclk = NULL; } - clk_use(clk); clk_enable(clk); ourport->clksrc = clksrc; @@ -1077,9 +1075,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, ourport->clk = clk_get(&platdev->dev, "uart"); - if (ourport->clk != NULL && !IS_ERR(ourport->clk)) - clk_use(ourport->clk); - dbg("port: map=%08x, mem=%08x, irq=%d, clock=%ld\n", port->mapbase, port->membase, port->irq, port->uartclk); diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index 35cc9402adc..add198a4be7 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c @@ -363,7 +363,6 @@ int usb_hcd_s3c2410_probe (const struct hc_driver *driver, goto err1; } - clk_use(clk); s3c2410_start_hc(dev, hcd); hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); @@ -384,7 +383,6 @@ int usb_hcd_s3c2410_probe (const struct hc_driver *driver, err2: s3c2410_stop_hc(dev); iounmap(hcd->regs); - clk_unuse(clk); clk_put(clk); err1: diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c index a3c2c45e29e..69421c86252 100644 --- a/drivers/video/amba-clcd.c +++ b/drivers/video/amba-clcd.c @@ -346,10 +346,6 @@ static int clcdfb_register(struct clcd_fb *fb) goto out; } - ret = clk_use(fb->clk); - if (ret) - goto free_clk; - fb->fb.fix.mmio_start = fb->dev->res.start; fb->fb.fix.mmio_len = SZ_4K; @@ -357,7 +353,7 @@ static int clcdfb_register(struct clcd_fb *fb) if (!fb->regs) { printk(KERN_ERR "CLCD: unable to remap registers\n"); ret = -ENOMEM; - goto unuse_clk; + goto free_clk; } fb->fb.fbops = &clcdfb_ops; @@ -427,8 +423,6 @@ static int clcdfb_register(struct clcd_fb *fb) printk(KERN_ERR "CLCD: cannot register framebuffer (%d)\n", ret); iounmap(fb->regs); - unuse_clk: - clk_unuse(fb->clk); free_clk: clk_put(fb->clk); out: @@ -489,7 +483,6 @@ static int clcdfb_remove(struct amba_device *dev) clcdfb_disable(fb); unregister_framebuffer(&fb->fb); iounmap(fb->regs); - clk_unuse(fb->clk); clk_put(fb->clk); fb->board->remove(fb); diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c index ce6e749db3a..d9c08cc7ac4 100644 --- a/drivers/video/s3c2410fb.c +++ b/drivers/video/s3c2410fb.c @@ -746,7 +746,6 @@ int __init s3c2410fb_probe(struct platform_device *pdev) goto release_irq; } - clk_use(info->clk); clk_enable(info->clk); dprintk("got and enabled clock\n"); @@ -783,7 +782,6 @@ free_video_memory: s3c2410fb_unmap_video_memory(info); release_clock: clk_disable(info->clk); - clk_unuse(info->clk); clk_put(info->clk); release_irq: free_irq(irq,info); @@ -828,7 +826,6 @@ static int s3c2410fb_remove(struct platform_device *pdev) if (info->clk) { clk_disable(info->clk); - clk_unuse(info->clk); clk_put(info->clk); info->clk = NULL; } -- cgit v1.2.3 From b7557de41a04346cb545d4dda7088760cb96e713 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 5 Jan 2006 20:44:55 +0000 Subject: [ARM] 3228/1: SharpSL: Move PM code to arch/arm/common Patch from Richard Purdie This patch moves a large chunk of the sharpsl_pm driver to arch/arm/common so that it can be reused on other devices such as the SL-5500 (collie). It also abstracts some functions from the core into the machine and platform specific parts of the driver to aid reuse. Signed-off-by: Richard Purdie Signed-off-by: Russell King --- drivers/video/backlight/corgi_bl.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c index 6a219b2c77e..d0aaf450e8c 100644 --- a/drivers/video/backlight/corgi_bl.c +++ b/drivers/video/backlight/corgi_bl.c @@ -20,6 +20,7 @@ #include #include +#include #define CORGI_DEFAULT_INTENSITY 0x1f #define CORGI_LIMIT_MASK 0x0b -- cgit v1.2.3 From 945b957972844881002ab4f68534581f4427a30b Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 5 Jan 2006 20:44:57 +0000 Subject: [ARM] 3230/1: Sharp Scoop: Fix Shared Power Control Issues Patch from Richard Purdie The SL-Cxx00 devices have a power control register in SCOOP that is shared by both CF and MMC/SD card slots. The CF reset code was resetting this register leading to various lockups as the MMC power was suddenly lost. This patch handles the CPR register in a more sensitive manner. It also removes some unneeded collie specific calls as the reset code handles this. Signed-off-by: Richard Purdie Signed-off-by: Russell King --- drivers/pcmcia/pxa2xx_sharpsl.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c index 56c58831e80..4fbd995360b 100644 --- a/drivers/pcmcia/pxa2xx_sharpsl.c +++ b/drivers/pcmcia/pxa2xx_sharpsl.c @@ -36,9 +36,18 @@ struct scoop_pcmcia_config *platform_scoop_config; #define SCOOP_DEV platform_scoop_config->devs -static void sharpsl_pcmcia_init_reset(struct scoop_pcmcia_dev *scoopdev) +static void sharpsl_pcmcia_init_reset(struct soc_pcmcia_socket *skt) { + struct scoop_pcmcia_dev *scoopdev = &SCOOP_DEV[skt->nr]; + reset_scoop(scoopdev->dev); + + /* Shared power controls need to be handled carefully */ + if (platform_scoop_config->power_ctrl) + platform_scoop_config->power_ctrl(scoopdev->dev, 0x0000, skt->nr); + else + write_scoop_reg(scoopdev->dev, SCOOP_CPR, 0x0000); + scoopdev->keep_vs = NO_KEEP_VS; scoopdev->keep_rd = 0; } @@ -208,26 +217,17 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, static void sharpsl_pcmcia_socket_init(struct soc_pcmcia_socket *skt) { - sharpsl_pcmcia_init_reset(&SCOOP_DEV[skt->nr]); + sharpsl_pcmcia_init_reset(skt); /* Enable interrupt */ write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_IMR, 0x00C0); write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_MCR, 0x0101); SCOOP_DEV[skt->nr].keep_vs = NO_KEEP_VS; - - if (machine_is_collie()) - /* We need to disable SS_OUTPUT_ENA here. */ - write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR, read_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR) & ~0x0080); } static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) { - /* CF_BUS_OFF */ - sharpsl_pcmcia_init_reset(&SCOOP_DEV[skt->nr]); - - if (machine_is_collie()) - /* We need to disable SS_OUTPUT_ENA here. */ - write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR, read_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR) & ~0x0080); + sharpsl_pcmcia_init_reset(skt); } static struct pcmcia_low_level sharpsl_pcmcia_ops = { -- cgit v1.2.3 From f99c89297cd6995ccad6394c87383941c2570fe9 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Sat, 7 Jan 2006 10:44:32 +0000 Subject: [ARM] 3232/1: i.MX Frame Buffer undeclared "dev" variable fix Patch from Pavel Pisa Correction of the code broken by update whole-tree platform devices update. Signed-off-by: Pavel Pisa Signed-off-by: Sascha Hauer Signed-off-by: Russell King --- drivers/video/imxfb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c index 5924cc225c9..1718baaeed2 100644 --- a/drivers/video/imxfb.c +++ b/drivers/video/imxfb.c @@ -554,7 +554,7 @@ static int __init imxfb_probe(struct platform_device *pdev) inf = pdev->dev.platform_data; if(!inf) { - dev_err(dev,"No platform_data available\n"); + dev_err(&pdev->dev,"No platform_data available\n"); return -ENOMEM; } @@ -579,7 +579,7 @@ static int __init imxfb_probe(struct platform_device *pdev) if (!inf->fixed_screen_cpu) { ret = imxfb_map_video_memory(info); if (ret) { - dev_err(dev, "Failed to allocate video RAM: %d\n", ret); + dev_err(&pdev->dev, "Failed to allocate video RAM: %d\n", ret); ret = -ENOMEM; goto failed_map; } @@ -608,7 +608,7 @@ static int __init imxfb_probe(struct platform_device *pdev) imxfb_set_par(info); ret = register_framebuffer(info); if (ret < 0) { - dev_err(dev, "failed to register framebuffer\n"); + dev_err(&pdev->dev, "failed to register framebuffer\n"); goto failed_register; } -- cgit v1.2.3 From a62c80e559809e6c7851ec04d30575e85ad6f6ed Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 7 Jan 2006 13:52:45 +0000 Subject: [ARM] Move AMBA include files to include/linux/amba/ Since the ARM AMBA bus is used on MIPS as well as ARM, we need to make the bus available for other architectures to use. Move the AMBA include files from include/asm-arm/hardware/ to include/linux/amba/ Signed-off-by: Russell King --- drivers/input/serio/ambakmi.c | 4 ++-- drivers/mmc/mmci.c | 2 +- drivers/serial/amba-pl010.c | 4 ++-- drivers/serial/amba-pl011.c | 4 ++-- drivers/video/amba-clcd.c | 5 ++--- 5 files changed, 9 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c index d847ed51cfb..cbab5d26377 100644 --- a/drivers/input/serio/ambakmi.c +++ b/drivers/input/serio/ambakmi.c @@ -19,11 +19,11 @@ #include #include #include +#include +#include #include #include -#include -#include #include #define KMI_BASE (kmi->base) diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c index 31b0b6d612b..57375bc1237 100644 --- a/drivers/mmc/mmci.c +++ b/drivers/mmc/mmci.c @@ -19,12 +19,12 @@ #include #include #include +#include #include #include #include #include -#include #include #include diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c index ddd0307fece..48f6e872314 100644 --- a/drivers/serial/amba-pl010.c +++ b/drivers/serial/amba-pl010.c @@ -47,12 +47,12 @@ #include #include #include +#include +#include #include #include #include -#include -#include #define UART_NR 2 diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c index 531b0e4f25e..4ae4dff5979 100644 --- a/drivers/serial/amba-pl011.c +++ b/drivers/serial/amba-pl011.c @@ -47,12 +47,12 @@ #include #include #include +#include +#include #include #include -#include #include -#include #define UART_NR 14 diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c index 69421c86252..3358a142965 100644 --- a/drivers/video/amba-clcd.c +++ b/drivers/video/amba-clcd.c @@ -21,13 +21,12 @@ #include #include #include +#include +#include #include -#include #include -#include - #define to_clcd(info) container_of(info, struct clcd_fb, fb) /* This is limited to 16 characters when displayed by X startup */ -- cgit v1.2.3 From de1d815fccee1f4766a7e56054ab0ec3f6f3a7db Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 7 Jan 2006 14:54:15 +0000 Subject: [ARM] Move AMBA bus code to drivers/amba/ Make the AMBA bus code visible to other architectures. Signed-off-by: Russell King --- drivers/Makefile | 1 + drivers/amba/Makefile | 2 + drivers/amba/bus.c | 359 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 362 insertions(+) create mode 100644 drivers/amba/Makefile create mode 100644 drivers/amba/bus.c (limited to 'drivers') diff --git a/drivers/Makefile b/drivers/Makefile index ea410b6b764..7fc3f0f08b2 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_ACPI) += acpi/ # PnP must come after ACPI since it will eventually need to check if acpi # was used and do nothing if so obj-$(CONFIG_PNP) += pnp/ +obj-$(CONFIG_ARM_AMBA) += amba/ # char/ comes before serial/ etc so that the VT console is the boot-time # default. diff --git a/drivers/amba/Makefile b/drivers/amba/Makefile new file mode 100644 index 00000000000..40fe74097be --- /dev/null +++ b/drivers/amba/Makefile @@ -0,0 +1,2 @@ +obj-y += bus.o + diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c new file mode 100644 index 00000000000..1bbdd1693d5 --- /dev/null +++ b/drivers/amba/bus.c @@ -0,0 +1,359 @@ +/* + * linux/arch/arm/common/amba.c + * + * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define to_amba_device(d) container_of(d, struct amba_device, dev) +#define to_amba_driver(d) container_of(d, struct amba_driver, drv) + +static struct amba_id * +amba_lookup(struct amba_id *table, struct amba_device *dev) +{ + int ret = 0; + + while (table->mask) { + ret = (dev->periphid & table->mask) == table->id; + if (ret) + break; + table++; + } + + return ret ? table : NULL; +} + +static int amba_match(struct device *dev, struct device_driver *drv) +{ + struct amba_device *pcdev = to_amba_device(dev); + struct amba_driver *pcdrv = to_amba_driver(drv); + + return amba_lookup(pcdrv->id_table, pcdev) != NULL; +} + +#ifdef CONFIG_HOTPLUG +static int amba_uevent(struct device *dev, char **envp, int nr_env, char *buf, int bufsz) +{ + struct amba_device *pcdev = to_amba_device(dev); + + if (nr_env < 2) + return -ENOMEM; + + snprintf(buf, bufsz, "AMBA_ID=%08x", pcdev->periphid); + *envp++ = buf; + *envp++ = NULL; + return 0; +} +#else +#define amba_uevent NULL +#endif + +static int amba_suspend(struct device *dev, pm_message_t state) +{ + struct amba_driver *drv = to_amba_driver(dev->driver); + int ret = 0; + + if (dev->driver && drv->suspend) + ret = drv->suspend(to_amba_device(dev), state); + return ret; +} + +static int amba_resume(struct device *dev) +{ + struct amba_driver *drv = to_amba_driver(dev->driver); + int ret = 0; + + if (dev->driver && drv->resume) + ret = drv->resume(to_amba_device(dev)); + return ret; +} + +/* + * Primecells are part of the Advanced Microcontroller Bus Architecture, + * so we call the bus "amba". + */ +static struct bus_type amba_bustype = { + .name = "amba", + .match = amba_match, + .uevent = amba_uevent, + .suspend = amba_suspend, + .resume = amba_resume, +}; + +static int __init amba_init(void) +{ + return bus_register(&amba_bustype); +} + +postcore_initcall(amba_init); + +/* + * These are the device model conversion veneers; they convert the + * device model structures to our more specific structures. + */ +static int amba_probe(struct device *dev) +{ + struct amba_device *pcdev = to_amba_device(dev); + struct amba_driver *pcdrv = to_amba_driver(dev->driver); + struct amba_id *id; + + id = amba_lookup(pcdrv->id_table, pcdev); + + return pcdrv->probe(pcdev, id); +} + +static int amba_remove(struct device *dev) +{ + struct amba_driver *drv = to_amba_driver(dev->driver); + return drv->remove(to_amba_device(dev)); +} + +static void amba_shutdown(struct device *dev) +{ + struct amba_driver *drv = to_amba_driver(dev->driver); + drv->shutdown(to_amba_device(dev)); +} + +/** + * amba_driver_register - register an AMBA device driver + * @drv: amba device driver structure + * + * Register an AMBA device driver with the Linux device model + * core. If devices pre-exist, the drivers probe function will + * be called. + */ +int amba_driver_register(struct amba_driver *drv) +{ + drv->drv.bus = &amba_bustype; + +#define SETFN(fn) if (drv->fn) drv->drv.fn = amba_##fn + SETFN(probe); + SETFN(remove); + SETFN(shutdown); + + return driver_register(&drv->drv); +} + +/** + * amba_driver_unregister - remove an AMBA device driver + * @drv: AMBA device driver structure to remove + * + * Unregister an AMBA device driver from the Linux device + * model. The device model will call the drivers remove function + * for each device the device driver is currently handling. + */ +void amba_driver_unregister(struct amba_driver *drv) +{ + driver_unregister(&drv->drv); +} + + +static void amba_device_release(struct device *dev) +{ + struct amba_device *d = to_amba_device(dev); + + if (d->res.parent) + release_resource(&d->res); + kfree(d); +} + +#define amba_attr(name,fmt,arg...) \ +static ssize_t show_##name(struct device *_dev, struct device_attribute *attr, char *buf) \ +{ \ + struct amba_device *dev = to_amba_device(_dev); \ + return sprintf(buf, fmt, arg); \ +} \ +static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) + +amba_attr(id, "%08x\n", dev->periphid); +amba_attr(irq0, "%u\n", dev->irq[0]); +amba_attr(irq1, "%u\n", dev->irq[1]); +amba_attr(resource, "\t%08lx\t%08lx\t%08lx\n", + dev->res.start, dev->res.end, dev->res.flags); + +/** + * amba_device_register - register an AMBA device + * @dev: AMBA device to register + * @parent: parent memory resource + * + * Setup the AMBA device, reading the cell ID if present. + * Claim the resource, and register the AMBA device with + * the Linux device manager. + */ +int amba_device_register(struct amba_device *dev, struct resource *parent) +{ + u32 pid, cid; + void __iomem *tmp; + int i, ret; + + dev->dev.release = amba_device_release; + dev->dev.bus = &amba_bustype; + dev->dev.dma_mask = &dev->dma_mask; + dev->res.name = dev->dev.bus_id; + + if (!dev->dev.coherent_dma_mask && dev->dma_mask) + dev_warn(&dev->dev, "coherent dma mask is unset\n"); + + ret = request_resource(parent, &dev->res); + if (ret == 0) { + tmp = ioremap(dev->res.start, SZ_4K); + if (!tmp) { + ret = -ENOMEM; + goto out; + } + + for (pid = 0, i = 0; i < 4; i++) + pid |= (readl(tmp + 0xfe0 + 4 * i) & 255) << (i * 8); + for (cid = 0, i = 0; i < 4; i++) + cid |= (readl(tmp + 0xff0 + 4 * i) & 255) << (i * 8); + + iounmap(tmp); + + if (cid == 0xb105f00d) + dev->periphid = pid; + + if (dev->periphid) + ret = device_register(&dev->dev); + else + ret = -ENODEV; + + if (ret == 0) { + device_create_file(&dev->dev, &dev_attr_id); + if (dev->irq[0] != NO_IRQ) + device_create_file(&dev->dev, &dev_attr_irq0); + if (dev->irq[1] != NO_IRQ) + device_create_file(&dev->dev, &dev_attr_irq1); + device_create_file(&dev->dev, &dev_attr_resource); + } else { + out: + release_resource(&dev->res); + } + } + return ret; +} + +/** + * amba_device_unregister - unregister an AMBA device + * @dev: AMBA device to remove + * + * Remove the specified AMBA device from the Linux device + * manager. All files associated with this object will be + * destroyed, and device drivers notified that the device has + * been removed. The AMBA device's resources including + * the amba_device structure will be freed once all + * references to it have been dropped. + */ +void amba_device_unregister(struct amba_device *dev) +{ + device_unregister(&dev->dev); +} + + +struct find_data { + struct amba_device *dev; + struct device *parent; + const char *busid; + unsigned int id; + unsigned int mask; +}; + +static int amba_find_match(struct device *dev, void *data) +{ + struct find_data *d = data; + struct amba_device *pcdev = to_amba_device(dev); + int r; + + r = (pcdev->periphid & d->mask) == d->id; + if (d->parent) + r &= d->parent == dev->parent; + if (d->busid) + r &= strcmp(dev->bus_id, d->busid) == 0; + + if (r) { + get_device(dev); + d->dev = pcdev; + } + + return r; +} + +/** + * amba_find_device - locate an AMBA device given a bus id + * @busid: bus id for device (or NULL) + * @parent: parent device (or NULL) + * @id: peripheral ID (or 0) + * @mask: peripheral ID mask (or 0) + * + * Return the AMBA device corresponding to the supplied parameters. + * If no device matches, returns NULL. + * + * NOTE: When a valid device is found, its refcount is + * incremented, and must be decremented before the returned + * reference. + */ +struct amba_device * +amba_find_device(const char *busid, struct device *parent, unsigned int id, + unsigned int mask) +{ + struct find_data data; + + data.dev = NULL; + data.parent = parent; + data.busid = busid; + data.id = id; + data.mask = mask; + + bus_for_each_dev(&amba_bustype, NULL, &data, amba_find_match); + + return data.dev; +} + +/** + * amba_request_regions - request all mem regions associated with device + * @dev: amba_device structure for device + * @name: name, or NULL to use driver name + */ +int amba_request_regions(struct amba_device *dev, const char *name) +{ + int ret = 0; + + if (!name) + name = dev->dev.driver->name; + + if (!request_mem_region(dev->res.start, SZ_4K, name)) + ret = -EBUSY; + + return ret; +} + +/** + * amba_release_regions - release mem regions assoicated with device + * @dev: amba_device structure for device + * + * Release regions claimed by a successful call to amba_request_regions. + */ +void amba_release_regions(struct amba_device *dev) +{ + release_mem_region(dev->res.start, SZ_4K); +} + +EXPORT_SYMBOL(amba_driver_register); +EXPORT_SYMBOL(amba_driver_unregister); +EXPORT_SYMBOL(amba_device_register); +EXPORT_SYMBOL(amba_device_unregister); +EXPORT_SYMBOL(amba_find_device); +EXPORT_SYMBOL(amba_request_regions); +EXPORT_SYMBOL(amba_release_regions); -- cgit v1.2.3 From f8ce25476d5f12ffa29b885e49c38cd95053437e Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 7 Jan 2006 16:15:52 +0000 Subject: [ARM] Move asm/hardware/clock.h to linux/clk.h This is needs to be visible to other architectures using the AMBA bus and peripherals. Signed-off-by: Russell King --- drivers/char/s3c2410-rtc.c | 2 +- drivers/char/watchdog/s3c2410_wdt.c | 2 +- drivers/i2c/busses/i2c-s3c2410.c | 2 +- drivers/input/serio/ambakmi.c | 2 +- drivers/mmc/mmci.c | 2 +- drivers/mtd/nand/s3c2410.c | 2 +- drivers/serial/amba-pl011.c | 2 +- drivers/serial/s3c2410.c | 2 +- drivers/usb/host/ohci-omap.c | 2 +- drivers/usb/host/ohci-s3c2410.c | 2 +- drivers/video/amba-clcd.c | 2 +- drivers/video/s3c2410fb.c | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers') diff --git a/drivers/char/s3c2410-rtc.c b/drivers/char/s3c2410-rtc.c index 3df7a574267..2e308657f6f 100644 --- a/drivers/char/s3c2410-rtc.c +++ b/drivers/char/s3c2410-rtc.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -33,7 +34,6 @@ #include -#include #include /* need this for the RTC_AF definitions */ diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c index 621e8a99e73..9dc54736e4e 100644 --- a/drivers/char/watchdog/s3c2410_wdt.c +++ b/drivers/char/watchdog/s3c2410_wdt.c @@ -46,12 +46,12 @@ #include #include #include +#include #include #include #include -#include #undef S3C24XX_VA_WATCHDOG #define S3C24XX_VA_WATCHDOG (0) diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 2a2f86d8c2d..f7d40f8e5f5 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -34,12 +34,12 @@ #include #include #include +#include #include #include #include -#include #include #include #include diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c index cbab5d26377..3df5eedf8f3 100644 --- a/drivers/input/serio/ambakmi.c +++ b/drivers/input/serio/ambakmi.c @@ -21,10 +21,10 @@ #include #include #include +#include #include #include -#include #define KMI_BASE (kmi->base) diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c index 57375bc1237..a0cd916ab79 100644 --- a/drivers/mmc/mmci.c +++ b/drivers/mmc/mmci.c @@ -20,12 +20,12 @@ #include #include #include +#include #include #include #include #include -#include #include #include "mmci.h" diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index b796a9a6b92..5b55599739f 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -60,7 +61,6 @@ #include #include -#include #include #include diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c index 4ae4dff5979..12967055616 100644 --- a/drivers/serial/amba-pl011.c +++ b/drivers/serial/amba-pl011.c @@ -49,10 +49,10 @@ #include #include #include +#include #include #include -#include #define UART_NR 14 diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c index eb47f5b71ae..fe83ce6fef5 100644 --- a/drivers/serial/s3c2410.c +++ b/drivers/serial/s3c2410.c @@ -72,12 +72,12 @@ #include #include #include +#include #include #include #include -#include #include #include diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index c9e29d80871..3785b3f7df1 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c @@ -17,6 +17,7 @@ #include /* SA_INTERRUPT */ #include #include +#include #include #include @@ -27,7 +28,6 @@ #include #include #include -#include /* OMAP-1510 OHCI has its own MMU for DMA */ diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index add198a4be7..372527a8359 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c @@ -20,9 +20,9 @@ */ #include +#include #include -#include #include #define valid_port(idx) ((idx) == 1 || (idx) == 2) diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c index 3358a142965..0da4083ba90 100644 --- a/drivers/video/amba-clcd.c +++ b/drivers/video/amba-clcd.c @@ -23,9 +23,9 @@ #include #include #include +#include #include -#include #define to_clcd(info) container_of(info, struct clcd_fb, fb) diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c index d9c08cc7ac4..fe99d17a21d 100644 --- a/drivers/video/s3c2410fb.c +++ b/drivers/video/s3c2410fb.c @@ -87,6 +87,7 @@ #include #include #include +#include #include #include @@ -96,7 +97,6 @@ #include #include #include -#include #ifdef CONFIG_PM #include -- cgit v1.2.3