diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/cdrom/gdrom.c | 10 | ||||
-rw-r--r-- | drivers/input/keyboard/sh_keysc.c | 2 | ||||
-rw-r--r-- | drivers/mfd/Kconfig | 8 | ||||
-rw-r--r-- | drivers/mfd/Makefile | 1 | ||||
-rw-r--r-- | drivers/mfd/sh_mobile_sdhi.c | 156 | ||||
-rw-r--r-- | drivers/mmc/host/Kconfig | 2 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1302.c | 2 | ||||
-rw-r--r-- | drivers/serial/Kconfig | 2 | ||||
-rw-r--r-- | drivers/serial/sh-sci.c | 59 | ||||
-rw-r--r-- | drivers/serial/sh-sci.h | 2 | ||||
-rw-r--r-- | drivers/sh/Makefile | 1 | ||||
-rw-r--r-- | drivers/sh/intc.c | 123 | ||||
-rw-r--r-- | drivers/sh/maple/maple.c | 4 | ||||
-rw-r--r-- | drivers/sh/pfc.c | 577 | ||||
-rw-r--r-- | drivers/video/sh_mobile_lcdcfb.c | 32 |
15 files changed, 892 insertions, 89 deletions
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c index a762283d2a21..e789e6c9a422 100644 --- a/drivers/cdrom/gdrom.c +++ b/drivers/cdrom/gdrom.c | |||
@@ -214,7 +214,7 @@ static void gdrom_spicommand(void *spi_string, int buflen) | |||
214 | gdrom_getsense(NULL); | 214 | gdrom_getsense(NULL); |
215 | return; | 215 | return; |
216 | } | 216 | } |
217 | outsw(PHYSADDR(GDROM_DATA_REG), cmd, 6); | 217 | outsw(GDROM_DATA_REG, cmd, 6); |
218 | } | 218 | } |
219 | 219 | ||
220 | 220 | ||
@@ -298,7 +298,7 @@ static int gdrom_readtoc_cmd(struct gdromtoc *toc, int session) | |||
298 | err = -EINVAL; | 298 | err = -EINVAL; |
299 | goto cleanup_readtoc; | 299 | goto cleanup_readtoc; |
300 | } | 300 | } |
301 | insw(PHYSADDR(GDROM_DATA_REG), toc, tocsize/2); | 301 | insw(GDROM_DATA_REG, toc, tocsize/2); |
302 | if (gd.status & 0x01) | 302 | if (gd.status & 0x01) |
303 | err = -EINVAL; | 303 | err = -EINVAL; |
304 | 304 | ||
@@ -449,7 +449,7 @@ static int gdrom_getsense(short *bufstring) | |||
449 | GDROM_DEFAULT_TIMEOUT); | 449 | GDROM_DEFAULT_TIMEOUT); |
450 | if (gd.pending) | 450 | if (gd.pending) |
451 | goto cleanup_sense; | 451 | goto cleanup_sense; |
452 | insw(PHYSADDR(GDROM_DATA_REG), &sense, sense_command->buflen/2); | 452 | insw(GDROM_DATA_REG, &sense, sense_command->buflen/2); |
453 | if (sense[1] & 40) { | 453 | if (sense[1] & 40) { |
454 | printk(KERN_INFO "GDROM: Drive not ready - command aborted\n"); | 454 | printk(KERN_INFO "GDROM: Drive not ready - command aborted\n"); |
455 | goto cleanup_sense; | 455 | goto cleanup_sense; |
@@ -586,7 +586,7 @@ static void gdrom_readdisk_dma(struct work_struct *work) | |||
586 | spin_unlock(&gdrom_lock); | 586 | spin_unlock(&gdrom_lock); |
587 | block = blk_rq_pos(req)/GD_TO_BLK + GD_SESSION_OFFSET; | 587 | block = blk_rq_pos(req)/GD_TO_BLK + GD_SESSION_OFFSET; |
588 | block_cnt = blk_rq_sectors(req)/GD_TO_BLK; | 588 | block_cnt = blk_rq_sectors(req)/GD_TO_BLK; |
589 | ctrl_outl(PHYSADDR(req->buffer), GDROM_DMA_STARTADDR_REG); | 589 | ctrl_outl(virt_to_phys(req->buffer), GDROM_DMA_STARTADDR_REG); |
590 | ctrl_outl(block_cnt * GDROM_HARD_SECTOR, GDROM_DMA_LENGTH_REG); | 590 | ctrl_outl(block_cnt * GDROM_HARD_SECTOR, GDROM_DMA_LENGTH_REG); |
591 | ctrl_outl(1, GDROM_DMA_DIRECTION_REG); | 591 | ctrl_outl(1, GDROM_DMA_DIRECTION_REG); |
592 | ctrl_outl(1, GDROM_DMA_ENABLE_REG); | 592 | ctrl_outl(1, GDROM_DMA_ENABLE_REG); |
@@ -615,7 +615,7 @@ static void gdrom_readdisk_dma(struct work_struct *work) | |||
615 | cpu_relax(); | 615 | cpu_relax(); |
616 | gd.pending = 1; | 616 | gd.pending = 1; |
617 | gd.transfer = 1; | 617 | gd.transfer = 1; |
618 | outsw(PHYSADDR(GDROM_DATA_REG), &read_command->cmd, 6); | 618 | outsw(GDROM_DATA_REG, &read_command->cmd, 6); |
619 | timeout = jiffies + HZ / 2; | 619 | timeout = jiffies + HZ / 2; |
620 | /* Wait for any pending DMA to finish */ | 620 | /* Wait for any pending DMA to finish */ |
621 | while (ctrl_inb(GDROM_DMA_STATUS_REG) && | 621 | while (ctrl_inb(GDROM_DMA_STATUS_REG) && |
diff --git a/drivers/input/keyboard/sh_keysc.c b/drivers/input/keyboard/sh_keysc.c index 887af79b7bff..076111fc72d2 100644 --- a/drivers/input/keyboard/sh_keysc.c +++ b/drivers/input/keyboard/sh_keysc.c | |||
@@ -18,9 +18,9 @@ | |||
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/input.h> | 20 | #include <linux/input.h> |
21 | #include <linux/input/sh_keysc.h> | ||
21 | #include <linux/clk.h> | 22 | #include <linux/clk.h> |
22 | #include <linux/io.h> | 23 | #include <linux/io.h> |
23 | #include <asm/sh_keysc.h> | ||
24 | 24 | ||
25 | #define KYCR1_OFFS 0x00 | 25 | #define KYCR1_OFFS 0x00 |
26 | #define KYCR2_OFFS 0x04 | 26 | #define KYCR2_OFFS 0x04 |
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 08f2d07bf56a..a296e717e86e 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -35,6 +35,14 @@ config MFD_ASIC3 | |||
35 | This driver supports the ASIC3 multifunction chip found on many | 35 | This driver supports the ASIC3 multifunction chip found on many |
36 | PDAs (mainly iPAQ and HTC based ones) | 36 | PDAs (mainly iPAQ and HTC based ones) |
37 | 37 | ||
38 | config MFD_SH_MOBILE_SDHI | ||
39 | bool "Support for SuperH Mobile SDHI" | ||
40 | depends on SUPERH | ||
41 | select MFD_CORE | ||
42 | ---help--- | ||
43 | This driver supports the SDHI hardware block found in many | ||
44 | SuperH Mobile SoCs. | ||
45 | |||
38 | config MFD_DM355EVM_MSP | 46 | config MFD_DM355EVM_MSP |
39 | bool "DaVinci DM355 EVM microcontroller" | 47 | bool "DaVinci DM355 EVM microcontroller" |
40 | depends on I2C && MACH_DAVINCI_DM355_EVM | 48 | depends on I2C && MACH_DAVINCI_DM355_EVM |
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index af0fc903cec8..11350c1d9301 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile | |||
@@ -4,6 +4,7 @@ | |||
4 | 4 | ||
5 | obj-$(CONFIG_MFD_SM501) += sm501.o | 5 | obj-$(CONFIG_MFD_SM501) += sm501.o |
6 | obj-$(CONFIG_MFD_ASIC3) += asic3.o | 6 | obj-$(CONFIG_MFD_ASIC3) += asic3.o |
7 | obj-$(CONFIG_MFD_SH_MOBILE_SDHI) += sh_mobile_sdhi.o | ||
7 | 8 | ||
8 | obj-$(CONFIG_HTC_EGPIO) += htc-egpio.o | 9 | obj-$(CONFIG_HTC_EGPIO) += htc-egpio.o |
9 | obj-$(CONFIG_HTC_PASIC3) += htc-pasic3.o | 10 | obj-$(CONFIG_HTC_PASIC3) += htc-pasic3.o |
diff --git a/drivers/mfd/sh_mobile_sdhi.c b/drivers/mfd/sh_mobile_sdhi.c new file mode 100644 index 000000000000..03efae8041ab --- /dev/null +++ b/drivers/mfd/sh_mobile_sdhi.c | |||
@@ -0,0 +1,156 @@ | |||
1 | /* | ||
2 | * SuperH Mobile SDHI | ||
3 | * | ||
4 | * Copyright (C) 2009 Magnus Damm | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | * | ||
10 | * Based on "Compaq ASIC3 support": | ||
11 | * | ||
12 | * Copyright 2001 Compaq Computer Corporation. | ||
13 | * Copyright 2004-2005 Phil Blundell | ||
14 | * Copyright 2007-2008 OpenedHand Ltd. | ||
15 | * | ||
16 | * Authors: Phil Blundell <pb@handhelds.org>, | ||
17 | * Samuel Ortiz <sameo@openedhand.com> | ||
18 | * | ||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/clk.h> | ||
23 | #include <linux/platform_device.h> | ||
24 | |||
25 | #include <linux/mfd/core.h> | ||
26 | #include <linux/mfd/tmio.h> | ||
27 | #include <linux/mfd/sh_mobile_sdhi.h> | ||
28 | |||
29 | struct sh_mobile_sdhi { | ||
30 | struct clk *clk; | ||
31 | struct tmio_mmc_data mmc_data; | ||
32 | struct mfd_cell cell_mmc; | ||
33 | }; | ||
34 | |||
35 | static struct resource sh_mobile_sdhi_resources[] = { | ||
36 | { | ||
37 | .start = 0x000, | ||
38 | .end = 0x1ff, | ||
39 | .flags = IORESOURCE_MEM, | ||
40 | }, | ||
41 | { | ||
42 | .start = 0, | ||
43 | .end = 0, | ||
44 | .flags = IORESOURCE_IRQ, | ||
45 | }, | ||
46 | }; | ||
47 | |||
48 | static struct mfd_cell sh_mobile_sdhi_cell = { | ||
49 | .name = "tmio-mmc", | ||
50 | .num_resources = ARRAY_SIZE(sh_mobile_sdhi_resources), | ||
51 | .resources = sh_mobile_sdhi_resources, | ||
52 | }; | ||
53 | |||
54 | static void sh_mobile_sdhi_set_pwr(struct platform_device *tmio, int state) | ||
55 | { | ||
56 | struct platform_device *pdev = to_platform_device(tmio->dev.parent); | ||
57 | struct sh_mobile_sdhi_info *p = pdev->dev.platform_data; | ||
58 | |||
59 | if (p && p->set_pwr) | ||
60 | p->set_pwr(pdev, state); | ||
61 | } | ||
62 | |||
63 | static int __init sh_mobile_sdhi_probe(struct platform_device *pdev) | ||
64 | { | ||
65 | struct sh_mobile_sdhi *priv; | ||
66 | struct resource *mem; | ||
67 | char clk_name[8]; | ||
68 | int ret, irq; | ||
69 | |||
70 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
71 | if (!mem) | ||
72 | dev_err(&pdev->dev, "missing MEM resource\n"); | ||
73 | |||
74 | irq = platform_get_irq(pdev, 0); | ||
75 | if (irq < 0) | ||
76 | dev_err(&pdev->dev, "missing IRQ resource\n"); | ||
77 | |||
78 | if (!mem || (irq < 0)) | ||
79 | return -EINVAL; | ||
80 | |||
81 | priv = kzalloc(sizeof(struct sh_mobile_sdhi), GFP_KERNEL); | ||
82 | if (priv == NULL) { | ||
83 | dev_err(&pdev->dev, "kzalloc failed\n"); | ||
84 | return -ENOMEM; | ||
85 | } | ||
86 | |||
87 | snprintf(clk_name, sizeof(clk_name), "sdhi%d", pdev->id); | ||
88 | priv->clk = clk_get(&pdev->dev, clk_name); | ||
89 | if (IS_ERR(priv->clk)) { | ||
90 | dev_err(&pdev->dev, "cannot get clock \"%s\"\n", clk_name); | ||
91 | ret = PTR_ERR(priv->clk); | ||
92 | kfree(priv); | ||
93 | return ret; | ||
94 | } | ||
95 | |||
96 | clk_enable(priv->clk); | ||
97 | |||
98 | /* FIXME: silly const unsigned int hclk */ | ||
99 | *(unsigned int *)&priv->mmc_data.hclk = clk_get_rate(priv->clk); | ||
100 | priv->mmc_data.set_pwr = sh_mobile_sdhi_set_pwr; | ||
101 | |||
102 | memcpy(&priv->cell_mmc, &sh_mobile_sdhi_cell, sizeof(priv->cell_mmc)); | ||
103 | priv->cell_mmc.driver_data = &priv->mmc_data; | ||
104 | priv->cell_mmc.platform_data = &priv->cell_mmc; | ||
105 | priv->cell_mmc.data_size = sizeof(priv->cell_mmc); | ||
106 | |||
107 | platform_set_drvdata(pdev, priv); | ||
108 | |||
109 | ret = mfd_add_devices(&pdev->dev, pdev->id, | ||
110 | &priv->cell_mmc, 1, mem, irq); | ||
111 | if (ret) { | ||
112 | clk_disable(priv->clk); | ||
113 | clk_put(priv->clk); | ||
114 | kfree(priv); | ||
115 | } | ||
116 | |||
117 | return ret; | ||
118 | } | ||
119 | |||
120 | static int sh_mobile_sdhi_remove(struct platform_device *pdev) | ||
121 | { | ||
122 | struct sh_mobile_sdhi *priv = platform_get_drvdata(pdev); | ||
123 | |||
124 | mfd_remove_devices(&pdev->dev); | ||
125 | clk_disable(priv->clk); | ||
126 | clk_put(priv->clk); | ||
127 | kfree(priv); | ||
128 | |||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | static struct platform_driver sh_mobile_sdhi_driver = { | ||
133 | .driver = { | ||
134 | .name = "sh_mobile_sdhi", | ||
135 | .owner = THIS_MODULE, | ||
136 | }, | ||
137 | .probe = sh_mobile_sdhi_probe, | ||
138 | .remove = __devexit_p(sh_mobile_sdhi_remove), | ||
139 | }; | ||
140 | |||
141 | static int __init sh_mobile_sdhi_init(void) | ||
142 | { | ||
143 | return platform_driver_register(&sh_mobile_sdhi_driver); | ||
144 | } | ||
145 | |||
146 | static void __exit sh_mobile_sdhi_exit(void) | ||
147 | { | ||
148 | platform_driver_unregister(&sh_mobile_sdhi_driver); | ||
149 | } | ||
150 | |||
151 | module_init(sh_mobile_sdhi_init); | ||
152 | module_exit(sh_mobile_sdhi_exit); | ||
153 | |||
154 | MODULE_DESCRIPTION("SuperH Mobile SDHI driver"); | ||
155 | MODULE_AUTHOR("Magnus Damm"); | ||
156 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index 432ae8358c86..e04b751680d0 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig | |||
@@ -329,7 +329,7 @@ config MMC_SDRICOH_CS | |||
329 | 329 | ||
330 | config MMC_TMIO | 330 | config MMC_TMIO |
331 | tristate "Toshiba Mobile IO Controller (TMIO) MMC/SD function support" | 331 | tristate "Toshiba Mobile IO Controller (TMIO) MMC/SD function support" |
332 | depends on MFD_TMIO || MFD_ASIC3 | 332 | depends on MFD_TMIO || MFD_ASIC3 || SUPERH |
333 | help | 333 | help |
334 | This provides support for the SD/MMC cell found in TC6393XB, | 334 | This provides support for the SD/MMC cell found in TC6393XB, |
335 | T7L66XB and also HTC ASIC3 | 335 | T7L66XB and also HTC ASIC3 |
diff --git a/drivers/rtc/rtc-ds1302.c b/drivers/rtc/rtc-ds1302.c index d490628b64da..1e73c8f42e38 100644 --- a/drivers/rtc/rtc-ds1302.c +++ b/drivers/rtc/rtc-ds1302.c | |||
@@ -201,7 +201,7 @@ static struct platform_driver ds1302_platform_driver = { | |||
201 | .name = DRV_NAME, | 201 | .name = DRV_NAME, |
202 | .owner = THIS_MODULE, | 202 | .owner = THIS_MODULE, |
203 | }, | 203 | }, |
204 | .remove = __exit_p(ds1302_rtc_remove), | 204 | .remove = __devexit_p(ds1302_rtc_remove), |
205 | }; | 205 | }; |
206 | 206 | ||
207 | static int __init ds1302_rtc_init(void) | 207 | static int __init ds1302_rtc_init(void) |
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index 50943ff78f4b..9ff47db0b2ce 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig | |||
@@ -996,7 +996,7 @@ config SERIAL_IP22_ZILOG_CONSOLE | |||
996 | 996 | ||
997 | config SERIAL_SH_SCI | 997 | config SERIAL_SH_SCI |
998 | tristate "SuperH SCI(F) serial port support" | 998 | tristate "SuperH SCI(F) serial port support" |
999 | depends on SUPERH || H8300 | 999 | depends on HAVE_CLK && (SUPERH || H8300) |
1000 | select SERIAL_CORE | 1000 | select SERIAL_CORE |
1001 | 1001 | ||
1002 | config SERIAL_SH_SCI_NR_UARTS | 1002 | config SERIAL_SH_SCI_NR_UARTS |
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c index 6498bd1fb6dd..ff38dbdb5c6e 100644 --- a/drivers/serial/sh-sci.c +++ b/drivers/serial/sh-sci.c | |||
@@ -50,7 +50,6 @@ | |||
50 | #include <linux/list.h> | 50 | #include <linux/list.h> |
51 | 51 | ||
52 | #ifdef CONFIG_SUPERH | 52 | #ifdef CONFIG_SUPERH |
53 | #include <asm/clock.h> | ||
54 | #include <asm/sh_bios.h> | 53 | #include <asm/sh_bios.h> |
55 | #endif | 54 | #endif |
56 | 55 | ||
@@ -79,22 +78,18 @@ struct sci_port { | |||
79 | struct timer_list break_timer; | 78 | struct timer_list break_timer; |
80 | int break_flag; | 79 | int break_flag; |
81 | 80 | ||
82 | #ifdef CONFIG_HAVE_CLK | ||
83 | /* Interface clock */ | 81 | /* Interface clock */ |
84 | struct clk *iclk; | 82 | struct clk *iclk; |
85 | /* Data clock */ | 83 | /* Data clock */ |
86 | struct clk *dclk; | 84 | struct clk *dclk; |
87 | #endif | 85 | |
88 | struct list_head node; | 86 | struct list_head node; |
89 | }; | 87 | }; |
90 | 88 | ||
91 | struct sh_sci_priv { | 89 | struct sh_sci_priv { |
92 | spinlock_t lock; | 90 | spinlock_t lock; |
93 | struct list_head ports; | 91 | struct list_head ports; |
94 | |||
95 | #ifdef CONFIG_HAVE_CLK | ||
96 | struct notifier_block clk_nb; | 92 | struct notifier_block clk_nb; |
97 | #endif | ||
98 | }; | 93 | }; |
99 | 94 | ||
100 | /* Function prototypes */ | 95 | /* Function prototypes */ |
@@ -156,32 +151,6 @@ static void sci_poll_put_char(struct uart_port *port, unsigned char c) | |||
156 | } | 151 | } |
157 | #endif /* CONFIG_CONSOLE_POLL || CONFIG_SERIAL_SH_SCI_CONSOLE */ | 152 | #endif /* CONFIG_CONSOLE_POLL || CONFIG_SERIAL_SH_SCI_CONSOLE */ |
158 | 153 | ||
159 | #if defined(__H8300S__) | ||
160 | enum { sci_disable, sci_enable }; | ||
161 | |||
162 | static void h8300_sci_config(struct uart_port *port, unsigned int ctrl) | ||
163 | { | ||
164 | volatile unsigned char *mstpcrl = (volatile unsigned char *)MSTPCRL; | ||
165 | int ch = (port->mapbase - SMR0) >> 3; | ||
166 | unsigned char mask = 1 << (ch+1); | ||
167 | |||
168 | if (ctrl == sci_disable) | ||
169 | *mstpcrl |= mask; | ||
170 | else | ||
171 | *mstpcrl &= ~mask; | ||
172 | } | ||
173 | |||
174 | static void h8300_sci_enable(struct uart_port *port) | ||
175 | { | ||
176 | h8300_sci_config(port, sci_enable); | ||
177 | } | ||
178 | |||
179 | static void h8300_sci_disable(struct uart_port *port) | ||
180 | { | ||
181 | h8300_sci_config(port, sci_disable); | ||
182 | } | ||
183 | #endif | ||
184 | |||
185 | #if defined(__H8300H__) || defined(__H8300S__) | 154 | #if defined(__H8300H__) || defined(__H8300S__) |
186 | static void sci_init_pins(struct uart_port *port, unsigned int cflag) | 155 | static void sci_init_pins(struct uart_port *port, unsigned int cflag) |
187 | { | 156 | { |
@@ -733,7 +702,6 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr) | |||
733 | return ret; | 702 | return ret; |
734 | } | 703 | } |
735 | 704 | ||
736 | #ifdef CONFIG_HAVE_CLK | ||
737 | /* | 705 | /* |
738 | * Here we define a transistion notifier so that we can update all of our | 706 | * Here we define a transistion notifier so that we can update all of our |
739 | * ports' baud rate when the peripheral clock changes. | 707 | * ports' baud rate when the peripheral clock changes. |
@@ -751,7 +719,6 @@ static int sci_notifier(struct notifier_block *self, | |||
751 | spin_lock_irqsave(&priv->lock, flags); | 719 | spin_lock_irqsave(&priv->lock, flags); |
752 | list_for_each_entry(sci_port, &priv->ports, node) | 720 | list_for_each_entry(sci_port, &priv->ports, node) |
753 | sci_port->port.uartclk = clk_get_rate(sci_port->dclk); | 721 | sci_port->port.uartclk = clk_get_rate(sci_port->dclk); |
754 | |||
755 | spin_unlock_irqrestore(&priv->lock, flags); | 722 | spin_unlock_irqrestore(&priv->lock, flags); |
756 | } | 723 | } |
757 | 724 | ||
@@ -778,7 +745,6 @@ static void sci_clk_disable(struct uart_port *port) | |||
778 | 745 | ||
779 | clk_disable(sci_port->dclk); | 746 | clk_disable(sci_port->dclk); |
780 | } | 747 | } |
781 | #endif | ||
782 | 748 | ||
783 | static int sci_request_irq(struct sci_port *port) | 749 | static int sci_request_irq(struct sci_port *port) |
784 | { | 750 | { |
@@ -833,8 +799,8 @@ static void sci_free_irq(struct sci_port *port) | |||
833 | 799 | ||
834 | static unsigned int sci_tx_empty(struct uart_port *port) | 800 | static unsigned int sci_tx_empty(struct uart_port *port) |
835 | { | 801 | { |
836 | /* Can't detect */ | 802 | unsigned short status = sci_in(port, SCxSR); |
837 | return TIOCSER_TEMT; | 803 | return status & SCxSR_TEND(port) ? TIOCSER_TEMT : 0; |
838 | } | 804 | } |
839 | 805 | ||
840 | static void sci_set_mctrl(struct uart_port *port, unsigned int mctrl) | 806 | static void sci_set_mctrl(struct uart_port *port, unsigned int mctrl) |
@@ -1077,21 +1043,10 @@ static void __devinit sci_init_single(struct platform_device *dev, | |||
1077 | sci_port->port.iotype = UPIO_MEM; | 1043 | sci_port->port.iotype = UPIO_MEM; |
1078 | sci_port->port.line = index; | 1044 | sci_port->port.line = index; |
1079 | sci_port->port.fifosize = 1; | 1045 | sci_port->port.fifosize = 1; |
1080 | |||
1081 | #if defined(__H8300H__) || defined(__H8300S__) | ||
1082 | #ifdef __H8300S__ | ||
1083 | sci_port->enable = h8300_sci_enable; | ||
1084 | sci_port->disable = h8300_sci_disable; | ||
1085 | #endif | ||
1086 | sci_port->port.uartclk = CONFIG_CPU_CLOCK; | ||
1087 | #elif defined(CONFIG_HAVE_CLK) | ||
1088 | sci_port->iclk = p->clk ? clk_get(&dev->dev, p->clk) : NULL; | 1046 | sci_port->iclk = p->clk ? clk_get(&dev->dev, p->clk) : NULL; |
1089 | sci_port->dclk = clk_get(&dev->dev, "peripheral_clk"); | 1047 | sci_port->dclk = clk_get(&dev->dev, "peripheral_clk"); |
1090 | sci_port->enable = sci_clk_enable; | 1048 | sci_port->enable = sci_clk_enable; |
1091 | sci_port->disable = sci_clk_disable; | 1049 | sci_port->disable = sci_clk_disable; |
1092 | #else | ||
1093 | #error "Need a valid uartclk" | ||
1094 | #endif | ||
1095 | 1050 | ||
1096 | sci_port->break_timer.data = (unsigned long)sci_port; | 1051 | sci_port->break_timer.data = (unsigned long)sci_port; |
1097 | sci_port->break_timer.function = sci_break_timer; | 1052 | sci_port->break_timer.function = sci_break_timer; |
@@ -1106,7 +1061,6 @@ static void __devinit sci_init_single(struct platform_device *dev, | |||
1106 | sci_port->type = sci_port->port.type = p->type; | 1061 | sci_port->type = sci_port->port.type = p->type; |
1107 | 1062 | ||
1108 | memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs)); | 1063 | memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs)); |
1109 | |||
1110 | } | 1064 | } |
1111 | 1065 | ||
1112 | #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE | 1066 | #ifdef CONFIG_SERIAL_SH_SCI_CONSOLE |
@@ -1239,14 +1193,11 @@ static int sci_remove(struct platform_device *dev) | |||
1239 | struct sci_port *p; | 1193 | struct sci_port *p; |
1240 | unsigned long flags; | 1194 | unsigned long flags; |
1241 | 1195 | ||
1242 | #ifdef CONFIG_HAVE_CLK | ||
1243 | cpufreq_unregister_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER); | 1196 | cpufreq_unregister_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER); |
1244 | #endif | ||
1245 | 1197 | ||
1246 | spin_lock_irqsave(&priv->lock, flags); | 1198 | spin_lock_irqsave(&priv->lock, flags); |
1247 | list_for_each_entry(p, &priv->ports, node) | 1199 | list_for_each_entry(p, &priv->ports, node) |
1248 | uart_remove_one_port(&sci_uart_driver, &p->port); | 1200 | uart_remove_one_port(&sci_uart_driver, &p->port); |
1249 | |||
1250 | spin_unlock_irqrestore(&priv->lock, flags); | 1201 | spin_unlock_irqrestore(&priv->lock, flags); |
1251 | 1202 | ||
1252 | kfree(priv); | 1203 | kfree(priv); |
@@ -1307,10 +1258,8 @@ static int __devinit sci_probe(struct platform_device *dev) | |||
1307 | spin_lock_init(&priv->lock); | 1258 | spin_lock_init(&priv->lock); |
1308 | platform_set_drvdata(dev, priv); | 1259 | platform_set_drvdata(dev, priv); |
1309 | 1260 | ||
1310 | #ifdef CONFIG_HAVE_CLK | ||
1311 | priv->clk_nb.notifier_call = sci_notifier; | 1261 | priv->clk_nb.notifier_call = sci_notifier; |
1312 | cpufreq_register_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER); | 1262 | cpufreq_register_notifier(&priv->clk_nb, CPUFREQ_TRANSITION_NOTIFIER); |
1313 | #endif | ||
1314 | 1263 | ||
1315 | if (dev->id != -1) { | 1264 | if (dev->id != -1) { |
1316 | ret = sci_probe_single(dev, dev->id, p, &sci_ports[dev->id]); | 1265 | ret = sci_probe_single(dev, dev->id, p, &sci_ports[dev->id]); |
@@ -1370,7 +1319,7 @@ static struct dev_pm_ops sci_dev_pm_ops = { | |||
1370 | 1319 | ||
1371 | static struct platform_driver sci_driver = { | 1320 | static struct platform_driver sci_driver = { |
1372 | .probe = sci_probe, | 1321 | .probe = sci_probe, |
1373 | .remove = __devexit_p(sci_remove), | 1322 | .remove = sci_remove, |
1374 | .driver = { | 1323 | .driver = { |
1375 | .name = "sh-sci", | 1324 | .name = "sh-sci", |
1376 | .owner = THIS_MODULE, | 1325 | .owner = THIS_MODULE, |
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h index 3e2fcf93b42e..a32094eeb42b 100644 --- a/drivers/serial/sh-sci.h +++ b/drivers/serial/sh-sci.h | |||
@@ -1,5 +1,5 @@ | |||
1 | #include <linux/serial_core.h> | 1 | #include <linux/serial_core.h> |
2 | #include <asm/io.h> | 2 | #include <linux/io.h> |
3 | #include <linux/gpio.h> | 3 | #include <linux/gpio.h> |
4 | 4 | ||
5 | #if defined(CONFIG_H83007) || defined(CONFIG_H83068) | 5 | #if defined(CONFIG_H83007) || defined(CONFIG_H83068) |
diff --git a/drivers/sh/Makefile b/drivers/sh/Makefile index 6a025cefe6dc..4956bf1f2134 100644 --- a/drivers/sh/Makefile +++ b/drivers/sh/Makefile | |||
@@ -3,4 +3,5 @@ | |||
3 | # | 3 | # |
4 | obj-$(CONFIG_SUPERHYWAY) += superhyway/ | 4 | obj-$(CONFIG_SUPERHYWAY) += superhyway/ |
5 | obj-$(CONFIG_MAPLE) += maple/ | 5 | obj-$(CONFIG_MAPLE) += maple/ |
6 | obj-$(CONFIG_GENERIC_GPIO) += pfc.o | ||
6 | obj-y += intc.o | 7 | obj-y += intc.o |
diff --git a/drivers/sh/intc.c b/drivers/sh/intc.c index 559b5fe9dc0f..a7e5c2e9986c 100644 --- a/drivers/sh/intc.c +++ b/drivers/sh/intc.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * Shared interrupt handling code for IPR and INTC2 types of IRQs. | 2 | * Shared interrupt handling code for IPR and INTC2 types of IRQs. |
3 | * | 3 | * |
4 | * Copyright (C) 2007, 2008 Magnus Damm | 4 | * Copyright (C) 2007, 2008 Magnus Damm |
5 | * Copyright (C) 2009 Paul Mundt | ||
5 | * | 6 | * |
6 | * Based on intc2.c and ipr.c | 7 | * Based on intc2.c and ipr.c |
7 | * | 8 | * |
@@ -24,6 +25,7 @@ | |||
24 | #include <linux/sysdev.h> | 25 | #include <linux/sysdev.h> |
25 | #include <linux/list.h> | 26 | #include <linux/list.h> |
26 | #include <linux/topology.h> | 27 | #include <linux/topology.h> |
28 | #include <linux/bitmap.h> | ||
27 | 29 | ||
28 | #define _INTC_MK(fn, mode, addr_e, addr_d, width, shift) \ | 30 | #define _INTC_MK(fn, mode, addr_e, addr_d, width, shift) \ |
29 | ((shift) | ((width) << 5) | ((fn) << 9) | ((mode) << 13) | \ | 31 | ((shift) | ((width) << 5) | ((fn) << 9) | ((mode) << 13) | \ |
@@ -59,6 +61,20 @@ struct intc_desc_int { | |||
59 | 61 | ||
60 | static LIST_HEAD(intc_list); | 62 | static LIST_HEAD(intc_list); |
61 | 63 | ||
64 | /* | ||
65 | * The intc_irq_map provides a global map of bound IRQ vectors for a | ||
66 | * given platform. Allocation of IRQs are either static through the CPU | ||
67 | * vector map, or dynamic in the case of board mux vectors or MSI. | ||
68 | * | ||
69 | * As this is a central point for all IRQ controllers on the system, | ||
70 | * each of the available sources are mapped out here. This combined with | ||
71 | * sparseirq makes it quite trivial to keep the vector map tightly packed | ||
72 | * when dynamically creating IRQs, as well as tying in to otherwise | ||
73 | * unused irq_desc positions in the sparse array. | ||
74 | */ | ||
75 | static DECLARE_BITMAP(intc_irq_map, NR_IRQS); | ||
76 | static DEFINE_SPINLOCK(vector_lock); | ||
77 | |||
62 | #ifdef CONFIG_SMP | 78 | #ifdef CONFIG_SMP |
63 | #define IS_SMP(x) x.smp | 79 | #define IS_SMP(x) x.smp |
64 | #define INTC_REG(d, x, c) (d->reg[(x)] + ((d->smp[(x)] & 0xff) * c)) | 80 | #define INTC_REG(d, x, c) (d->reg[(x)] + ((d->smp[(x)] & 0xff) * c)) |
@@ -70,9 +86,7 @@ static LIST_HEAD(intc_list); | |||
70 | #endif | 86 | #endif |
71 | 87 | ||
72 | static unsigned int intc_prio_level[NR_IRQS]; /* for now */ | 88 | static unsigned int intc_prio_level[NR_IRQS]; /* for now */ |
73 | #if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A) | ||
74 | static unsigned long ack_handle[NR_IRQS]; | 89 | static unsigned long ack_handle[NR_IRQS]; |
75 | #endif | ||
76 | 90 | ||
77 | static inline struct intc_desc_int *get_intc_desc(unsigned int irq) | 91 | static inline struct intc_desc_int *get_intc_desc(unsigned int irq) |
78 | { | 92 | { |
@@ -250,7 +264,6 @@ static int intc_set_wake(unsigned int irq, unsigned int on) | |||
250 | return 0; /* allow wakeup, but setup hardware in intc_suspend() */ | 264 | return 0; /* allow wakeup, but setup hardware in intc_suspend() */ |
251 | } | 265 | } |
252 | 266 | ||
253 | #if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A) | ||
254 | static void intc_mask_ack(unsigned int irq) | 267 | static void intc_mask_ack(unsigned int irq) |
255 | { | 268 | { |
256 | struct intc_desc_int *d = get_intc_desc(irq); | 269 | struct intc_desc_int *d = get_intc_desc(irq); |
@@ -282,7 +295,6 @@ static void intc_mask_ack(unsigned int irq) | |||
282 | } | 295 | } |
283 | } | 296 | } |
284 | } | 297 | } |
285 | #endif | ||
286 | 298 | ||
287 | static struct intc_handle_int *intc_find_irq(struct intc_handle_int *hp, | 299 | static struct intc_handle_int *intc_find_irq(struct intc_handle_int *hp, |
288 | unsigned int nr_hp, | 300 | unsigned int nr_hp, |
@@ -501,7 +513,6 @@ static unsigned int __init intc_prio_data(struct intc_desc *desc, | |||
501 | return 0; | 513 | return 0; |
502 | } | 514 | } |
503 | 515 | ||
504 | #if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A) | ||
505 | static unsigned int __init intc_ack_data(struct intc_desc *desc, | 516 | static unsigned int __init intc_ack_data(struct intc_desc *desc, |
506 | struct intc_desc_int *d, | 517 | struct intc_desc_int *d, |
507 | intc_enum enum_id) | 518 | intc_enum enum_id) |
@@ -533,7 +544,6 @@ static unsigned int __init intc_ack_data(struct intc_desc *desc, | |||
533 | 544 | ||
534 | return 0; | 545 | return 0; |
535 | } | 546 | } |
536 | #endif | ||
537 | 547 | ||
538 | static unsigned int __init intc_sense_data(struct intc_desc *desc, | 548 | static unsigned int __init intc_sense_data(struct intc_desc *desc, |
539 | struct intc_desc_int *d, | 549 | struct intc_desc_int *d, |
@@ -572,6 +582,11 @@ static void __init intc_register_irq(struct intc_desc *desc, | |||
572 | struct intc_handle_int *hp; | 582 | struct intc_handle_int *hp; |
573 | unsigned int data[2], primary; | 583 | unsigned int data[2], primary; |
574 | 584 | ||
585 | /* | ||
586 | * Register the IRQ position with the global IRQ map | ||
587 | */ | ||
588 | set_bit(irq, intc_irq_map); | ||
589 | |||
575 | /* Prefer single interrupt source bitmap over other combinations: | 590 | /* Prefer single interrupt source bitmap over other combinations: |
576 | * 1. bitmap, single interrupt source | 591 | * 1. bitmap, single interrupt source |
577 | * 2. priority, single interrupt source | 592 | * 2. priority, single interrupt source |
@@ -641,10 +656,8 @@ static void __init intc_register_irq(struct intc_desc *desc, | |||
641 | /* irq should be disabled by default */ | 656 | /* irq should be disabled by default */ |
642 | d->chip.mask(irq); | 657 | d->chip.mask(irq); |
643 | 658 | ||
644 | #if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A) | ||
645 | if (desc->ack_regs) | 659 | if (desc->ack_regs) |
646 | ack_handle[irq] = intc_ack_data(desc, d, enum_id); | 660 | ack_handle[irq] = intc_ack_data(desc, d, enum_id); |
647 | #endif | ||
648 | } | 661 | } |
649 | 662 | ||
650 | static unsigned int __init save_reg(struct intc_desc_int *d, | 663 | static unsigned int __init save_reg(struct intc_desc_int *d, |
@@ -681,10 +694,8 @@ void __init register_intc_controller(struct intc_desc *desc) | |||
681 | d->nr_reg = desc->mask_regs ? desc->nr_mask_regs * 2 : 0; | 694 | d->nr_reg = desc->mask_regs ? desc->nr_mask_regs * 2 : 0; |
682 | d->nr_reg += desc->prio_regs ? desc->nr_prio_regs * 2 : 0; | 695 | d->nr_reg += desc->prio_regs ? desc->nr_prio_regs * 2 : 0; |
683 | d->nr_reg += desc->sense_regs ? desc->nr_sense_regs : 0; | 696 | d->nr_reg += desc->sense_regs ? desc->nr_sense_regs : 0; |
684 | |||
685 | #if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A) | ||
686 | d->nr_reg += desc->ack_regs ? desc->nr_ack_regs : 0; | 697 | d->nr_reg += desc->ack_regs ? desc->nr_ack_regs : 0; |
687 | #endif | 698 | |
688 | d->reg = kzalloc(d->nr_reg * sizeof(*d->reg), GFP_NOWAIT); | 699 | d->reg = kzalloc(d->nr_reg * sizeof(*d->reg), GFP_NOWAIT); |
689 | #ifdef CONFIG_SMP | 700 | #ifdef CONFIG_SMP |
690 | d->smp = kzalloc(d->nr_reg * sizeof(*d->smp), GFP_NOWAIT); | 701 | d->smp = kzalloc(d->nr_reg * sizeof(*d->smp), GFP_NOWAIT); |
@@ -727,14 +738,12 @@ void __init register_intc_controller(struct intc_desc *desc) | |||
727 | d->chip.set_type = intc_set_sense; | 738 | d->chip.set_type = intc_set_sense; |
728 | d->chip.set_wake = intc_set_wake; | 739 | d->chip.set_wake = intc_set_wake; |
729 | 740 | ||
730 | #if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4A) | ||
731 | if (desc->ack_regs) { | 741 | if (desc->ack_regs) { |
732 | for (i = 0; i < desc->nr_ack_regs; i++) | 742 | for (i = 0; i < desc->nr_ack_regs; i++) |
733 | k += save_reg(d, k, desc->ack_regs[i].set_reg, 0); | 743 | k += save_reg(d, k, desc->ack_regs[i].set_reg, 0); |
734 | 744 | ||
735 | d->chip.mask_ack = intc_mask_ack; | 745 | d->chip.mask_ack = intc_mask_ack; |
736 | } | 746 | } |
737 | #endif | ||
738 | 747 | ||
739 | BUG_ON(k > 256); /* _INTC_ADDR_E() and _INTC_ADDR_D() are 8 bits */ | 748 | BUG_ON(k > 256); /* _INTC_ADDR_E() and _INTC_ADDR_D() are 8 bits */ |
740 | 749 | ||
@@ -856,5 +865,91 @@ static int __init register_intc_sysdevs(void) | |||
856 | 865 | ||
857 | return error; | 866 | return error; |
858 | } | 867 | } |
859 | |||
860 | device_initcall(register_intc_sysdevs); | 868 | device_initcall(register_intc_sysdevs); |
869 | |||
870 | /* | ||
871 | * Dynamic IRQ allocation and deallocation | ||
872 | */ | ||
873 | static unsigned int create_irq_on_node(unsigned int irq_want, int node) | ||
874 | { | ||
875 | unsigned int irq = 0, new; | ||
876 | unsigned long flags; | ||
877 | struct irq_desc *desc; | ||
878 | |||
879 | spin_lock_irqsave(&vector_lock, flags); | ||
880 | |||
881 | /* | ||
882 | * First try the wanted IRQ, then scan. | ||
883 | */ | ||
884 | if (test_and_set_bit(irq_want, intc_irq_map)) { | ||
885 | new = find_first_zero_bit(intc_irq_map, nr_irqs); | ||
886 | if (unlikely(new == nr_irqs)) | ||
887 | goto out_unlock; | ||
888 | |||
889 | desc = irq_to_desc_alloc_node(new, node); | ||
890 | if (unlikely(!desc)) { | ||
891 | pr_info("can't get irq_desc for %d\n", new); | ||
892 | goto out_unlock; | ||
893 | } | ||
894 | |||
895 | desc = move_irq_desc(desc, node); | ||
896 | __set_bit(new, intc_irq_map); | ||
897 | irq = new; | ||
898 | } | ||
899 | |||
900 | out_unlock: | ||
901 | spin_unlock_irqrestore(&vector_lock, flags); | ||
902 | |||
903 | if (irq > 0) | ||
904 | dynamic_irq_init(irq); | ||
905 | |||
906 | return irq; | ||
907 | } | ||
908 | |||
909 | int create_irq(void) | ||
910 | { | ||
911 | int nid = cpu_to_node(smp_processor_id()); | ||
912 | int irq; | ||
913 | |||
914 | irq = create_irq_on_node(NR_IRQS_LEGACY, nid); | ||
915 | if (irq == 0) | ||
916 | irq = -1; | ||
917 | |||
918 | return irq; | ||
919 | } | ||
920 | |||
921 | void destroy_irq(unsigned int irq) | ||
922 | { | ||
923 | unsigned long flags; | ||
924 | |||
925 | dynamic_irq_cleanup(irq); | ||
926 | |||
927 | spin_lock_irqsave(&vector_lock, flags); | ||
928 | __clear_bit(irq, intc_irq_map); | ||
929 | spin_unlock_irqrestore(&vector_lock, flags); | ||
930 | } | ||
931 | |||
932 | int reserve_irq_vector(unsigned int irq) | ||
933 | { | ||
934 | unsigned long flags; | ||
935 | int ret = 0; | ||
936 | |||
937 | spin_lock_irqsave(&vector_lock, flags); | ||
938 | if (test_and_set_bit(irq, intc_irq_map)) | ||
939 | ret = -EBUSY; | ||
940 | spin_unlock_irqrestore(&vector_lock, flags); | ||
941 | |||
942 | return ret; | ||
943 | } | ||
944 | |||
945 | void reserve_irq_legacy(void) | ||
946 | { | ||
947 | unsigned long flags; | ||
948 | int i, j; | ||
949 | |||
950 | spin_lock_irqsave(&vector_lock, flags); | ||
951 | j = find_first_bit(intc_irq_map, nr_irqs); | ||
952 | for (i = 0; i < j; i++) | ||
953 | __set_bit(i, intc_irq_map); | ||
954 | spin_unlock_irqrestore(&vector_lock, flags); | ||
955 | } | ||
diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c index 93c20e135ee1..4e8f57d4131f 100644 --- a/drivers/sh/maple/maple.c +++ b/drivers/sh/maple/maple.c | |||
@@ -106,7 +106,7 @@ static void maple_dma_reset(void) | |||
106 | * max delay is 11 | 106 | * max delay is 11 |
107 | */ | 107 | */ |
108 | ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(0xFFFF), MAPLE_SPEED); | 108 | ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(0xFFFF), MAPLE_SPEED); |
109 | ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR); | 109 | ctrl_outl(virt_to_phys(maple_sendbuf), MAPLE_DMAADDR); |
110 | ctrl_outl(1, MAPLE_ENABLE); | 110 | ctrl_outl(1, MAPLE_ENABLE); |
111 | } | 111 | } |
112 | 112 | ||
@@ -258,7 +258,7 @@ static void maple_build_block(struct mapleq *mq) | |||
258 | maple_lastptr = maple_sendptr; | 258 | maple_lastptr = maple_sendptr; |
259 | 259 | ||
260 | *maple_sendptr++ = (port << 16) | len | 0x80000000; | 260 | *maple_sendptr++ = (port << 16) | len | 0x80000000; |
261 | *maple_sendptr++ = PHYSADDR(mq->recvbuf->buf); | 261 | *maple_sendptr++ = virt_to_phys(mq->recvbuf->buf); |
262 | *maple_sendptr++ = | 262 | *maple_sendptr++ = |
263 | mq->command | (to << 8) | (from << 16) | (len << 24); | 263 | mq->command | (to << 8) | (from << 16) | (len << 24); |
264 | while (len-- > 0) | 264 | while (len-- > 0) |
diff --git a/drivers/sh/pfc.c b/drivers/sh/pfc.c new file mode 100644 index 000000000000..841ed5030c8f --- /dev/null +++ b/drivers/sh/pfc.c | |||
@@ -0,0 +1,577 @@ | |||
1 | /* | ||
2 | * Pinmuxed GPIO support for SuperH. | ||
3 | * | ||
4 | * Copyright (C) 2008 Magnus Damm | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file "COPYING" in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | #include <linux/errno.h> | ||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/list.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/clk.h> | ||
15 | #include <linux/err.h> | ||
16 | #include <linux/io.h> | ||
17 | #include <linux/irq.h> | ||
18 | #include <linux/bitops.h> | ||
19 | #include <linux/gpio.h> | ||
20 | |||
21 | static int enum_in_range(pinmux_enum_t enum_id, struct pinmux_range *r) | ||
22 | { | ||
23 | if (enum_id < r->begin) | ||
24 | return 0; | ||
25 | |||
26 | if (enum_id > r->end) | ||
27 | return 0; | ||
28 | |||
29 | return 1; | ||
30 | } | ||
31 | |||
32 | static unsigned long gpio_read_raw_reg(unsigned long reg, | ||
33 | unsigned long reg_width) | ||
34 | { | ||
35 | switch (reg_width) { | ||
36 | case 8: | ||
37 | return __raw_readb(reg); | ||
38 | case 16: | ||
39 | return __raw_readw(reg); | ||
40 | case 32: | ||
41 | return __raw_readl(reg); | ||
42 | } | ||
43 | |||
44 | BUG(); | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | static void gpio_write_raw_reg(unsigned long reg, | ||
49 | unsigned long reg_width, | ||
50 | unsigned long data) | ||
51 | { | ||
52 | switch (reg_width) { | ||
53 | case 8: | ||
54 | __raw_writeb(data, reg); | ||
55 | return; | ||
56 | case 16: | ||
57 | __raw_writew(data, reg); | ||
58 | return; | ||
59 | case 32: | ||
60 | __raw_writel(data, reg); | ||
61 | return; | ||
62 | } | ||
63 | |||
64 | BUG(); | ||
65 | } | ||
66 | |||
67 | static void gpio_write_bit(struct pinmux_data_reg *dr, | ||
68 | unsigned long in_pos, unsigned long value) | ||
69 | { | ||
70 | unsigned long pos; | ||
71 | |||
72 | pos = dr->reg_width - (in_pos + 1); | ||
73 | |||
74 | pr_debug("write_bit addr = %lx, value = %ld, pos = %ld, " | ||
75 | "r_width = %ld\n", | ||
76 | dr->reg, !!value, pos, dr->reg_width); | ||
77 | |||
78 | if (value) | ||
79 | set_bit(pos, &dr->reg_shadow); | ||
80 | else | ||
81 | clear_bit(pos, &dr->reg_shadow); | ||
82 | |||
83 | gpio_write_raw_reg(dr->reg, dr->reg_width, dr->reg_shadow); | ||
84 | } | ||
85 | |||
86 | static int gpio_read_reg(unsigned long reg, unsigned long reg_width, | ||
87 | unsigned long field_width, unsigned long in_pos) | ||
88 | { | ||
89 | unsigned long data, mask, pos; | ||
90 | |||
91 | data = 0; | ||
92 | mask = (1 << field_width) - 1; | ||
93 | pos = reg_width - ((in_pos + 1) * field_width); | ||
94 | |||
95 | pr_debug("read_reg: addr = %lx, pos = %ld, " | ||
96 | "r_width = %ld, f_width = %ld\n", | ||
97 | reg, pos, reg_width, field_width); | ||
98 | |||
99 | data = gpio_read_raw_reg(reg, reg_width); | ||
100 | return (data >> pos) & mask; | ||
101 | } | ||
102 | |||
103 | static void gpio_write_reg(unsigned long reg, unsigned long reg_width, | ||
104 | unsigned long field_width, unsigned long in_pos, | ||
105 | unsigned long value) | ||
106 | { | ||
107 | unsigned long mask, pos; | ||
108 | |||
109 | mask = (1 << field_width) - 1; | ||
110 | pos = reg_width - ((in_pos + 1) * field_width); | ||
111 | |||
112 | pr_debug("write_reg addr = %lx, value = %ld, pos = %ld, " | ||
113 | "r_width = %ld, f_width = %ld\n", | ||
114 | reg, value, pos, reg_width, field_width); | ||
115 | |||
116 | mask = ~(mask << pos); | ||
117 | value = value << pos; | ||
118 | |||
119 | switch (reg_width) { | ||
120 | case 8: | ||
121 | __raw_writeb((__raw_readb(reg) & mask) | value, reg); | ||
122 | break; | ||
123 | case 16: | ||
124 | __raw_writew((__raw_readw(reg) & mask) | value, reg); | ||
125 | break; | ||
126 | case 32: | ||
127 | __raw_writel((__raw_readl(reg) & mask) | value, reg); | ||
128 | break; | ||
129 | } | ||
130 | } | ||
131 | |||
132 | static int setup_data_reg(struct pinmux_info *gpioc, unsigned gpio) | ||
133 | { | ||
134 | struct pinmux_gpio *gpiop = &gpioc->gpios[gpio]; | ||
135 | struct pinmux_data_reg *data_reg; | ||
136 | int k, n; | ||
137 | |||
138 | if (!enum_in_range(gpiop->enum_id, &gpioc->data)) | ||
139 | return -1; | ||
140 | |||
141 | k = 0; | ||
142 | while (1) { | ||
143 | data_reg = gpioc->data_regs + k; | ||
144 | |||
145 | if (!data_reg->reg_width) | ||
146 | break; | ||
147 | |||
148 | for (n = 0; n < data_reg->reg_width; n++) { | ||
149 | if (data_reg->enum_ids[n] == gpiop->enum_id) { | ||
150 | gpiop->flags &= ~PINMUX_FLAG_DREG; | ||
151 | gpiop->flags |= (k << PINMUX_FLAG_DREG_SHIFT); | ||
152 | gpiop->flags &= ~PINMUX_FLAG_DBIT; | ||
153 | gpiop->flags |= (n << PINMUX_FLAG_DBIT_SHIFT); | ||
154 | return 0; | ||
155 | } | ||
156 | } | ||
157 | k++; | ||
158 | } | ||
159 | |||
160 | BUG(); | ||
161 | |||
162 | return -1; | ||
163 | } | ||
164 | |||
165 | static void setup_data_regs(struct pinmux_info *gpioc) | ||
166 | { | ||
167 | struct pinmux_data_reg *drp; | ||
168 | int k; | ||
169 | |||
170 | for (k = gpioc->first_gpio; k <= gpioc->last_gpio; k++) | ||
171 | setup_data_reg(gpioc, k); | ||
172 | |||
173 | k = 0; | ||
174 | while (1) { | ||
175 | drp = gpioc->data_regs + k; | ||
176 | |||
177 | if (!drp->reg_width) | ||
178 | break; | ||
179 | |||
180 | drp->reg_shadow = gpio_read_raw_reg(drp->reg, drp->reg_width); | ||
181 | k++; | ||
182 | } | ||
183 | } | ||
184 | |||
185 | static int get_data_reg(struct pinmux_info *gpioc, unsigned gpio, | ||
186 | struct pinmux_data_reg **drp, int *bitp) | ||
187 | { | ||
188 | struct pinmux_gpio *gpiop = &gpioc->gpios[gpio]; | ||
189 | int k, n; | ||
190 | |||
191 | if (!enum_in_range(gpiop->enum_id, &gpioc->data)) | ||
192 | return -1; | ||
193 | |||
194 | k = (gpiop->flags & PINMUX_FLAG_DREG) >> PINMUX_FLAG_DREG_SHIFT; | ||
195 | n = (gpiop->flags & PINMUX_FLAG_DBIT) >> PINMUX_FLAG_DBIT_SHIFT; | ||
196 | *drp = gpioc->data_regs + k; | ||
197 | *bitp = n; | ||
198 | return 0; | ||
199 | } | ||
200 | |||
201 | static int get_config_reg(struct pinmux_info *gpioc, pinmux_enum_t enum_id, | ||
202 | struct pinmux_cfg_reg **crp, int *indexp, | ||
203 | unsigned long **cntp) | ||
204 | { | ||
205 | struct pinmux_cfg_reg *config_reg; | ||
206 | unsigned long r_width, f_width; | ||
207 | int k, n; | ||
208 | |||
209 | k = 0; | ||
210 | while (1) { | ||
211 | config_reg = gpioc->cfg_regs + k; | ||
212 | |||
213 | r_width = config_reg->reg_width; | ||
214 | f_width = config_reg->field_width; | ||
215 | |||
216 | if (!r_width) | ||
217 | break; | ||
218 | for (n = 0; n < (r_width / f_width) * 1 << f_width; n++) { | ||
219 | if (config_reg->enum_ids[n] == enum_id) { | ||
220 | *crp = config_reg; | ||
221 | *indexp = n; | ||
222 | *cntp = &config_reg->cnt[n / (1 << f_width)]; | ||
223 | return 0; | ||
224 | } | ||
225 | } | ||
226 | k++; | ||
227 | } | ||
228 | |||
229 | return -1; | ||
230 | } | ||
231 | |||
232 | static int get_gpio_enum_id(struct pinmux_info *gpioc, unsigned gpio, | ||
233 | int pos, pinmux_enum_t *enum_idp) | ||
234 | { | ||
235 | pinmux_enum_t enum_id = gpioc->gpios[gpio].enum_id; | ||
236 | pinmux_enum_t *data = gpioc->gpio_data; | ||
237 | int k; | ||
238 | |||
239 | if (!enum_in_range(enum_id, &gpioc->data)) { | ||
240 | if (!enum_in_range(enum_id, &gpioc->mark)) { | ||
241 | pr_err("non data/mark enum_id for gpio %d\n", gpio); | ||
242 | return -1; | ||
243 | } | ||
244 | } | ||
245 | |||
246 | if (pos) { | ||
247 | *enum_idp = data[pos + 1]; | ||
248 | return pos + 1; | ||
249 | } | ||
250 | |||
251 | for (k = 0; k < gpioc->gpio_data_size; k++) { | ||
252 | if (data[k] == enum_id) { | ||
253 | *enum_idp = data[k + 1]; | ||
254 | return k + 1; | ||
255 | } | ||
256 | } | ||
257 | |||
258 | pr_err("cannot locate data/mark enum_id for gpio %d\n", gpio); | ||
259 | return -1; | ||
260 | } | ||
261 | |||
262 | static void write_config_reg(struct pinmux_info *gpioc, | ||
263 | struct pinmux_cfg_reg *crp, | ||
264 | int index) | ||
265 | { | ||
266 | unsigned long ncomb, pos, value; | ||
267 | |||
268 | ncomb = 1 << crp->field_width; | ||
269 | pos = index / ncomb; | ||
270 | value = index % ncomb; | ||
271 | |||
272 | gpio_write_reg(crp->reg, crp->reg_width, crp->field_width, pos, value); | ||
273 | } | ||
274 | |||
275 | static int check_config_reg(struct pinmux_info *gpioc, | ||
276 | struct pinmux_cfg_reg *crp, | ||
277 | int index) | ||
278 | { | ||
279 | unsigned long ncomb, pos, value; | ||
280 | |||
281 | ncomb = 1 << crp->field_width; | ||
282 | pos = index / ncomb; | ||
283 | value = index % ncomb; | ||
284 | |||
285 | if (gpio_read_reg(crp->reg, crp->reg_width, | ||
286 | crp->field_width, pos) == value) | ||
287 | return 0; | ||
288 | |||
289 | return -1; | ||
290 | } | ||
291 | |||
292 | enum { GPIO_CFG_DRYRUN, GPIO_CFG_REQ, GPIO_CFG_FREE }; | ||
293 | |||
294 | static int pinmux_config_gpio(struct pinmux_info *gpioc, unsigned gpio, | ||
295 | int pinmux_type, int cfg_mode) | ||
296 | { | ||
297 | struct pinmux_cfg_reg *cr = NULL; | ||
298 | pinmux_enum_t enum_id; | ||
299 | struct pinmux_range *range; | ||
300 | int in_range, pos, index; | ||
301 | unsigned long *cntp; | ||
302 | |||
303 | switch (pinmux_type) { | ||
304 | |||
305 | case PINMUX_TYPE_FUNCTION: | ||
306 | range = NULL; | ||
307 | break; | ||
308 | |||
309 | case PINMUX_TYPE_OUTPUT: | ||
310 | range = &gpioc->output; | ||
311 | break; | ||
312 | |||
313 | case PINMUX_TYPE_INPUT: | ||
314 | range = &gpioc->input; | ||
315 | break; | ||
316 | |||
317 | case PINMUX_TYPE_INPUT_PULLUP: | ||
318 | range = &gpioc->input_pu; | ||
319 | break; | ||
320 | |||
321 | case PINMUX_TYPE_INPUT_PULLDOWN: | ||
322 | range = &gpioc->input_pd; | ||
323 | break; | ||
324 | |||
325 | default: | ||
326 | goto out_err; | ||
327 | } | ||
328 | |||
329 | pos = 0; | ||
330 | enum_id = 0; | ||
331 | index = 0; | ||
332 | while (1) { | ||
333 | pos = get_gpio_enum_id(gpioc, gpio, pos, &enum_id); | ||
334 | if (pos <= 0) | ||
335 | goto out_err; | ||
336 | |||
337 | if (!enum_id) | ||
338 | break; | ||
339 | |||
340 | in_range = enum_in_range(enum_id, &gpioc->function); | ||
341 | if (!in_range && range) { | ||
342 | in_range = enum_in_range(enum_id, range); | ||
343 | |||
344 | if (in_range && enum_id == range->force) | ||
345 | continue; | ||
346 | } | ||
347 | |||
348 | if (!in_range) | ||
349 | continue; | ||
350 | |||
351 | if (get_config_reg(gpioc, enum_id, &cr, &index, &cntp) != 0) | ||
352 | goto out_err; | ||
353 | |||
354 | switch (cfg_mode) { | ||
355 | case GPIO_CFG_DRYRUN: | ||
356 | if (!*cntp || !check_config_reg(gpioc, cr, index)) | ||
357 | continue; | ||
358 | break; | ||
359 | |||
360 | case GPIO_CFG_REQ: | ||
361 | write_config_reg(gpioc, cr, index); | ||
362 | *cntp = *cntp + 1; | ||
363 | break; | ||
364 | |||
365 | case GPIO_CFG_FREE: | ||
366 | *cntp = *cntp - 1; | ||
367 | break; | ||
368 | } | ||
369 | } | ||
370 | |||
371 | return 0; | ||
372 | out_err: | ||
373 | return -1; | ||
374 | } | ||
375 | |||
376 | static DEFINE_SPINLOCK(gpio_lock); | ||
377 | |||
378 | static struct pinmux_info *chip_to_pinmux(struct gpio_chip *chip) | ||
379 | { | ||
380 | return container_of(chip, struct pinmux_info, chip); | ||
381 | } | ||
382 | |||
383 | static int sh_gpio_request(struct gpio_chip *chip, unsigned offset) | ||
384 | { | ||
385 | struct pinmux_info *gpioc = chip_to_pinmux(chip); | ||
386 | struct pinmux_data_reg *dummy; | ||
387 | unsigned long flags; | ||
388 | int i, ret, pinmux_type; | ||
389 | |||
390 | ret = -EINVAL; | ||
391 | |||
392 | if (!gpioc) | ||
393 | goto err_out; | ||
394 | |||
395 | spin_lock_irqsave(&gpio_lock, flags); | ||
396 | |||
397 | if ((gpioc->gpios[offset].flags & PINMUX_FLAG_TYPE) != PINMUX_TYPE_NONE) | ||
398 | goto err_unlock; | ||
399 | |||
400 | /* setup pin function here if no data is associated with pin */ | ||
401 | |||
402 | if (get_data_reg(gpioc, offset, &dummy, &i) != 0) | ||
403 | pinmux_type = PINMUX_TYPE_FUNCTION; | ||
404 | else | ||
405 | pinmux_type = PINMUX_TYPE_GPIO; | ||
406 | |||
407 | if (pinmux_type == PINMUX_TYPE_FUNCTION) { | ||
408 | if (pinmux_config_gpio(gpioc, offset, | ||
409 | pinmux_type, | ||
410 | GPIO_CFG_DRYRUN) != 0) | ||
411 | goto err_unlock; | ||
412 | |||
413 | if (pinmux_config_gpio(gpioc, offset, | ||
414 | pinmux_type, | ||
415 | GPIO_CFG_REQ) != 0) | ||
416 | BUG(); | ||
417 | } | ||
418 | |||
419 | gpioc->gpios[offset].flags &= ~PINMUX_FLAG_TYPE; | ||
420 | gpioc->gpios[offset].flags |= pinmux_type; | ||
421 | |||
422 | ret = 0; | ||
423 | err_unlock: | ||
424 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
425 | err_out: | ||
426 | return ret; | ||
427 | } | ||
428 | |||
429 | static void sh_gpio_free(struct gpio_chip *chip, unsigned offset) | ||
430 | { | ||
431 | struct pinmux_info *gpioc = chip_to_pinmux(chip); | ||
432 | unsigned long flags; | ||
433 | int pinmux_type; | ||
434 | |||
435 | if (!gpioc) | ||
436 | return; | ||
437 | |||
438 | spin_lock_irqsave(&gpio_lock, flags); | ||
439 | |||
440 | pinmux_type = gpioc->gpios[offset].flags & PINMUX_FLAG_TYPE; | ||
441 | pinmux_config_gpio(gpioc, offset, pinmux_type, GPIO_CFG_FREE); | ||
442 | gpioc->gpios[offset].flags &= ~PINMUX_FLAG_TYPE; | ||
443 | gpioc->gpios[offset].flags |= PINMUX_TYPE_NONE; | ||
444 | |||
445 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
446 | } | ||
447 | |||
448 | static int pinmux_direction(struct pinmux_info *gpioc, | ||
449 | unsigned gpio, int new_pinmux_type) | ||
450 | { | ||
451 | int pinmux_type; | ||
452 | int ret = -EINVAL; | ||
453 | |||
454 | if (!gpioc) | ||
455 | goto err_out; | ||
456 | |||
457 | pinmux_type = gpioc->gpios[gpio].flags & PINMUX_FLAG_TYPE; | ||
458 | |||
459 | switch (pinmux_type) { | ||
460 | case PINMUX_TYPE_GPIO: | ||
461 | break; | ||
462 | case PINMUX_TYPE_OUTPUT: | ||
463 | case PINMUX_TYPE_INPUT: | ||
464 | case PINMUX_TYPE_INPUT_PULLUP: | ||
465 | case PINMUX_TYPE_INPUT_PULLDOWN: | ||
466 | pinmux_config_gpio(gpioc, gpio, pinmux_type, GPIO_CFG_FREE); | ||
467 | break; | ||
468 | default: | ||
469 | goto err_out; | ||
470 | } | ||
471 | |||
472 | if (pinmux_config_gpio(gpioc, gpio, | ||
473 | new_pinmux_type, | ||
474 | GPIO_CFG_DRYRUN) != 0) | ||
475 | goto err_out; | ||
476 | |||
477 | if (pinmux_config_gpio(gpioc, gpio, | ||
478 | new_pinmux_type, | ||
479 | GPIO_CFG_REQ) != 0) | ||
480 | BUG(); | ||
481 | |||
482 | gpioc->gpios[gpio].flags &= ~PINMUX_FLAG_TYPE; | ||
483 | gpioc->gpios[gpio].flags |= new_pinmux_type; | ||
484 | |||
485 | ret = 0; | ||
486 | err_out: | ||
487 | return ret; | ||
488 | } | ||
489 | |||
490 | static int sh_gpio_direction_input(struct gpio_chip *chip, unsigned offset) | ||
491 | { | ||
492 | struct pinmux_info *gpioc = chip_to_pinmux(chip); | ||
493 | unsigned long flags; | ||
494 | int ret; | ||
495 | |||
496 | spin_lock_irqsave(&gpio_lock, flags); | ||
497 | ret = pinmux_direction(gpioc, offset, PINMUX_TYPE_INPUT); | ||
498 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
499 | |||
500 | return ret; | ||
501 | } | ||
502 | |||
503 | static void sh_gpio_set_value(struct pinmux_info *gpioc, | ||
504 | unsigned gpio, int value) | ||
505 | { | ||
506 | struct pinmux_data_reg *dr = NULL; | ||
507 | int bit = 0; | ||
508 | |||
509 | if (!gpioc || get_data_reg(gpioc, gpio, &dr, &bit) != 0) | ||
510 | BUG(); | ||
511 | else | ||
512 | gpio_write_bit(dr, bit, value); | ||
513 | } | ||
514 | |||
515 | static int sh_gpio_direction_output(struct gpio_chip *chip, unsigned offset, | ||
516 | int value) | ||
517 | { | ||
518 | struct pinmux_info *gpioc = chip_to_pinmux(chip); | ||
519 | unsigned long flags; | ||
520 | int ret; | ||
521 | |||
522 | sh_gpio_set_value(gpioc, offset, value); | ||
523 | spin_lock_irqsave(&gpio_lock, flags); | ||
524 | ret = pinmux_direction(gpioc, offset, PINMUX_TYPE_OUTPUT); | ||
525 | spin_unlock_irqrestore(&gpio_lock, flags); | ||
526 | |||
527 | return ret; | ||
528 | } | ||
529 | |||
530 | static int sh_gpio_get_value(struct pinmux_info *gpioc, unsigned gpio) | ||
531 | { | ||
532 | struct pinmux_data_reg *dr = NULL; | ||
533 | int bit = 0; | ||
534 | |||
535 | if (!gpioc || get_data_reg(gpioc, gpio, &dr, &bit) != 0) { | ||
536 | BUG(); | ||
537 | return 0; | ||
538 | } | ||
539 | |||
540 | return gpio_read_reg(dr->reg, dr->reg_width, 1, bit); | ||
541 | } | ||
542 | |||
543 | static int sh_gpio_get(struct gpio_chip *chip, unsigned offset) | ||
544 | { | ||
545 | return sh_gpio_get_value(chip_to_pinmux(chip), offset); | ||
546 | } | ||
547 | |||
548 | static void sh_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | ||
549 | { | ||
550 | sh_gpio_set_value(chip_to_pinmux(chip), offset, value); | ||
551 | } | ||
552 | |||
553 | int register_pinmux(struct pinmux_info *pip) | ||
554 | { | ||
555 | struct gpio_chip *chip = &pip->chip; | ||
556 | |||
557 | pr_info("sh pinmux: %s handling gpio %d -> %d\n", | ||
558 | pip->name, pip->first_gpio, pip->last_gpio); | ||
559 | |||
560 | setup_data_regs(pip); | ||
561 | |||
562 | chip->request = sh_gpio_request; | ||
563 | chip->free = sh_gpio_free; | ||
564 | chip->direction_input = sh_gpio_direction_input; | ||
565 | chip->get = sh_gpio_get; | ||
566 | chip->direction_output = sh_gpio_direction_output; | ||
567 | chip->set = sh_gpio_set; | ||
568 | |||
569 | WARN_ON(pip->first_gpio != 0); /* needs testing */ | ||
570 | |||
571 | chip->label = pip->name; | ||
572 | chip->owner = THIS_MODULE; | ||
573 | chip->base = pip->first_gpio; | ||
574 | chip->ngpio = (pip->last_gpio - pip->first_gpio) + 1; | ||
575 | |||
576 | return gpiochip_add(chip); | ||
577 | } | ||
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c index 3ad5157f9899..b4b5de930cf5 100644 --- a/drivers/video/sh_mobile_lcdcfb.c +++ b/drivers/video/sh_mobile_lcdcfb.c | |||
@@ -281,18 +281,34 @@ static void sh_mobile_lcdc_deferred_io(struct fb_info *info, | |||
281 | struct list_head *pagelist) | 281 | struct list_head *pagelist) |
282 | { | 282 | { |
283 | struct sh_mobile_lcdc_chan *ch = info->par; | 283 | struct sh_mobile_lcdc_chan *ch = info->par; |
284 | unsigned int nr_pages; | ||
285 | 284 | ||
286 | /* enable clocks before accessing hardware */ | 285 | /* enable clocks before accessing hardware */ |
287 | sh_mobile_lcdc_clk_on(ch->lcdc); | 286 | sh_mobile_lcdc_clk_on(ch->lcdc); |
288 | 287 | ||
289 | nr_pages = sh_mobile_lcdc_sginit(info, pagelist); | 288 | /* |
290 | dma_map_sg(info->dev, ch->sglist, nr_pages, DMA_TO_DEVICE); | 289 | * It's possible to get here without anything on the pagelist via |
291 | 290 | * sh_mobile_lcdc_deferred_io_touch() or via a userspace fsync() | |
292 | /* trigger panel update */ | 291 | * invocation. In the former case, the acceleration routines are |
293 | lcdc_write_chan(ch, LDSM2R, 1); | 292 | * stepped in to when using the framebuffer console causing the |
294 | 293 | * workqueue to be scheduled without any dirty pages on the list. | |
295 | dma_unmap_sg(info->dev, ch->sglist, nr_pages, DMA_TO_DEVICE); | 294 | * |
295 | * Despite this, a panel update is still needed given that the | ||
296 | * acceleration routines have their own methods for writing in | ||
297 | * that still need to be updated. | ||
298 | * | ||
299 | * The fsync() and empty pagelist case could be optimized for, | ||
300 | * but we don't bother, as any application exhibiting such | ||
301 | * behaviour is fundamentally broken anyways. | ||
302 | */ | ||
303 | if (!list_empty(pagelist)) { | ||
304 | unsigned int nr_pages = sh_mobile_lcdc_sginit(info, pagelist); | ||
305 | |||
306 | /* trigger panel update */ | ||
307 | dma_map_sg(info->dev, ch->sglist, nr_pages, DMA_TO_DEVICE); | ||
308 | lcdc_write_chan(ch, LDSM2R, 1); | ||
309 | dma_unmap_sg(info->dev, ch->sglist, nr_pages, DMA_TO_DEVICE); | ||
310 | } else | ||
311 | lcdc_write_chan(ch, LDSM2R, 1); | ||
296 | } | 312 | } |
297 | 313 | ||
298 | static void sh_mobile_lcdc_deferred_io_touch(struct fb_info *info) | 314 | static void sh_mobile_lcdc_deferred_io_touch(struct fb_info *info) |