diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/Makefile | 1 | ||||
-rw-r--r-- | drivers/block/viodasd.c | 49 | ||||
-rw-r--r-- | drivers/ide/pci/via82cxxx.c | 4 | ||||
-rw-r--r-- | drivers/macintosh/Kconfig | 7 | ||||
-rw-r--r-- | drivers/macintosh/Makefile | 1 | ||||
-rw-r--r-- | drivers/macintosh/rack-meter.c | 612 | ||||
-rw-r--r-- | drivers/macintosh/smu.c | 3 | ||||
-rw-r--r-- | drivers/macintosh/therm_adt746x.c | 2 | ||||
-rw-r--r-- | drivers/macintosh/therm_pm72.c | 5 | ||||
-rw-r--r-- | drivers/macintosh/therm_windtunnel.c | 7 | ||||
-rw-r--r-- | drivers/net/ibm_emac/ibm_emac_mal.h | 6 | ||||
-rw-r--r-- | drivers/net/ibmveth.c | 4 | ||||
-rw-r--r-- | drivers/net/ibmveth.h | 1 | ||||
-rw-r--r-- | drivers/net/phy/fixed.c | 2 | ||||
-rw-r--r-- | drivers/net/spider_net.c | 18 | ||||
-rw-r--r-- | drivers/net/tulip/de4x5.c | 8 | ||||
-rw-r--r-- | drivers/ps3/Makefile | 1 | ||||
-rw-r--r-- | drivers/ps3/system-bus.c | 362 | ||||
-rw-r--r-- | drivers/serial/cpm_uart/cpm_uart_cpm2.c | 2 | ||||
-rw-r--r-- | drivers/serial/mpc52xx_uart.c | 469 | ||||
-rw-r--r-- | drivers/video/platinumfb.c | 5 |
21 files changed, 1449 insertions, 120 deletions
diff --git a/drivers/Makefile b/drivers/Makefile index 4ac14dab307..67711770b1d 100644 --- a/drivers/Makefile +++ b/drivers/Makefile | |||
@@ -77,3 +77,4 @@ obj-$(CONFIG_CRYPTO) += crypto/ | |||
77 | obj-$(CONFIG_SUPERH) += sh/ | 77 | obj-$(CONFIG_SUPERH) += sh/ |
78 | obj-$(CONFIG_GENERIC_TIME) += clocksource/ | 78 | obj-$(CONFIG_GENERIC_TIME) += clocksource/ |
79 | obj-$(CONFIG_DMA_ENGINE) += dma/ | 79 | obj-$(CONFIG_DMA_ENGINE) += dma/ |
80 | obj-$(CONFIG_PPC_PS3) += ps3/ | ||
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c index ec5a1b90a0a..e19ba4ebcd4 100644 --- a/drivers/block/viodasd.c +++ b/drivers/block/viodasd.c | |||
@@ -759,6 +759,8 @@ static struct vio_driver viodasd_driver = { | |||
759 | } | 759 | } |
760 | }; | 760 | }; |
761 | 761 | ||
762 | static int need_delete_probe; | ||
763 | |||
762 | /* | 764 | /* |
763 | * Initialize the whole device driver. Handle module and non-module | 765 | * Initialize the whole device driver. Handle module and non-module |
764 | * versions | 766 | * versions |
@@ -773,46 +775,67 @@ static int __init viodasd_init(void) | |||
773 | 775 | ||
774 | if (viopath_hostLp == HvLpIndexInvalid) { | 776 | if (viopath_hostLp == HvLpIndexInvalid) { |
775 | printk(VIOD_KERN_WARNING "invalid hosting partition\n"); | 777 | printk(VIOD_KERN_WARNING "invalid hosting partition\n"); |
776 | return -EIO; | 778 | rc = -EIO; |
779 | goto early_fail; | ||
777 | } | 780 | } |
778 | 781 | ||
779 | printk(VIOD_KERN_INFO "vers " VIOD_VERS ", hosting partition %d\n", | 782 | printk(VIOD_KERN_INFO "vers " VIOD_VERS ", hosting partition %d\n", |
780 | viopath_hostLp); | 783 | viopath_hostLp); |
781 | 784 | ||
782 | /* register the block device */ | 785 | /* register the block device */ |
783 | if (register_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME)) { | 786 | rc = register_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME); |
787 | if (rc) { | ||
784 | printk(VIOD_KERN_WARNING | 788 | printk(VIOD_KERN_WARNING |
785 | "Unable to get major number %d for %s\n", | 789 | "Unable to get major number %d for %s\n", |
786 | VIODASD_MAJOR, VIOD_GENHD_NAME); | 790 | VIODASD_MAJOR, VIOD_GENHD_NAME); |
787 | return -EIO; | 791 | goto early_fail; |
788 | } | 792 | } |
789 | /* Actually open the path to the hosting partition */ | 793 | /* Actually open the path to the hosting partition */ |
790 | if (viopath_open(viopath_hostLp, viomajorsubtype_blockio, | 794 | rc = viopath_open(viopath_hostLp, viomajorsubtype_blockio, |
791 | VIOMAXREQ + 2)) { | 795 | VIOMAXREQ + 2); |
796 | if (rc) { | ||
792 | printk(VIOD_KERN_WARNING | 797 | printk(VIOD_KERN_WARNING |
793 | "error opening path to host partition %d\n", | 798 | "error opening path to host partition %d\n", |
794 | viopath_hostLp); | 799 | viopath_hostLp); |
795 | unregister_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME); | 800 | goto unregister_blk; |
796 | return -EIO; | ||
797 | } | 801 | } |
798 | 802 | ||
799 | /* Initialize our request handler */ | 803 | /* Initialize our request handler */ |
800 | vio_setHandler(viomajorsubtype_blockio, handle_block_event); | 804 | vio_setHandler(viomajorsubtype_blockio, handle_block_event); |
801 | 805 | ||
802 | rc = vio_register_driver(&viodasd_driver); | 806 | rc = vio_register_driver(&viodasd_driver); |
803 | if (rc == 0) | 807 | if (rc) { |
804 | driver_create_file(&viodasd_driver.driver, &driver_attr_probe); | 808 | printk(VIOD_KERN_WARNING "vio_register_driver failed\n"); |
809 | goto unset_handler; | ||
810 | } | ||
811 | |||
812 | /* | ||
813 | * If this call fails, it just means that we cannot dynamically | ||
814 | * add virtual disks, but the driver will still work fine for | ||
815 | * all existing disk, so ignore the failure. | ||
816 | */ | ||
817 | if (!driver_create_file(&viodasd_driver.driver, &driver_attr_probe)) | ||
818 | need_delete_probe = 1; | ||
819 | |||
820 | return 0; | ||
821 | |||
822 | unset_handler: | ||
823 | vio_clearHandler(viomajorsubtype_blockio); | ||
824 | viopath_close(viopath_hostLp, viomajorsubtype_blockio, VIOMAXREQ + 2); | ||
825 | unregister_blk: | ||
826 | unregister_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME); | ||
827 | early_fail: | ||
805 | return rc; | 828 | return rc; |
806 | } | 829 | } |
807 | module_init(viodasd_init); | 830 | module_init(viodasd_init); |
808 | 831 | ||
809 | void viodasd_exit(void) | 832 | void __exit viodasd_exit(void) |
810 | { | 833 | { |
811 | driver_remove_file(&viodasd_driver.driver, &driver_attr_probe); | 834 | if (need_delete_probe) |
835 | driver_remove_file(&viodasd_driver.driver, &driver_attr_probe); | ||
812 | vio_unregister_driver(&viodasd_driver); | 836 | vio_unregister_driver(&viodasd_driver); |
813 | vio_clearHandler(viomajorsubtype_blockio); | 837 | vio_clearHandler(viomajorsubtype_blockio); |
814 | unregister_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME); | ||
815 | viopath_close(viopath_hostLp, viomajorsubtype_blockio, VIOMAXREQ + 2); | 838 | viopath_close(viopath_hostLp, viomajorsubtype_blockio, VIOMAXREQ + 2); |
839 | unregister_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME); | ||
816 | } | 840 | } |
817 | |||
818 | module_exit(viodasd_exit); | 841 | module_exit(viodasd_exit); |
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index 2af634d7acf..eb7ab112c05 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c | |||
@@ -35,7 +35,7 @@ | |||
35 | #include <linux/ide.h> | 35 | #include <linux/ide.h> |
36 | #include <asm/io.h> | 36 | #include <asm/io.h> |
37 | 37 | ||
38 | #ifdef CONFIG_PPC_MULTIPLATFORM | 38 | #ifdef CONFIG_PPC_CHRP |
39 | #include <asm/processor.h> | 39 | #include <asm/processor.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
@@ -442,7 +442,7 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif) | |||
442 | hwif->speedproc = &via_set_drive; | 442 | hwif->speedproc = &via_set_drive; |
443 | 443 | ||
444 | 444 | ||
445 | #if defined(CONFIG_PPC_CHRP) && defined(CONFIG_PPC32) | 445 | #ifdef CONFIG_PPC_CHRP |
446 | if(machine_is(chrp) && _chrp_type == _CHRP_Pegasos) { | 446 | if(machine_is(chrp) && _chrp_type == _CHRP_Pegasos) { |
447 | hwif->irq = hwif->channel ? 15 : 14; | 447 | hwif->irq = hwif->channel ? 15 : 14; |
448 | } | 448 | } |
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig index 7f8477d3a66..92ccee85e2a 100644 --- a/drivers/macintosh/Kconfig +++ b/drivers/macintosh/Kconfig | |||
@@ -228,4 +228,11 @@ config ANSLCD | |||
228 | tristate "Support for ANS LCD display" | 228 | tristate "Support for ANS LCD display" |
229 | depends on ADB_CUDA && PPC_PMAC | 229 | depends on ADB_CUDA && PPC_PMAC |
230 | 230 | ||
231 | config PMAC_RACKMETER | ||
232 | tristate "Support for Apple XServe front panel LEDs" | ||
233 | depends on PPC_PMAC | ||
234 | help | ||
235 | This driver procides some support to control the front panel | ||
236 | blue LEDs "vu-meter" of the XServer macs. | ||
237 | |||
231 | endmenu | 238 | endmenu |
diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile index b53d45f87b0..2dfc3f4eaf4 100644 --- a/drivers/macintosh/Makefile +++ b/drivers/macintosh/Makefile | |||
@@ -42,3 +42,4 @@ obj-$(CONFIG_WINDFARM_PM112) += windfarm_pm112.o windfarm_smu_sat.o \ | |||
42 | windfarm_smu_sensors.o \ | 42 | windfarm_smu_sensors.o \ |
43 | windfarm_max6690_sensor.o \ | 43 | windfarm_max6690_sensor.o \ |
44 | windfarm_lm75_sensor.o windfarm_pid.o | 44 | windfarm_lm75_sensor.o windfarm_pid.o |
45 | obj-$(CONFIG_PMAC_RACKMETER) += rack-meter.o | ||
diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c new file mode 100644 index 00000000000..f1b6f563673 --- /dev/null +++ b/drivers/macintosh/rack-meter.c | |||
@@ -0,0 +1,612 @@ | |||
1 | /* | ||
2 | * RackMac vu-meter driver | ||
3 | * | ||
4 | * (c) Copyright 2006 Benjamin Herrenschmidt, IBM Corp. | ||
5 | * <benh@kernel.crashing.org> | ||
6 | * | ||
7 | * Released under the term of the GNU GPL v2. | ||
8 | * | ||
9 | * Support the CPU-meter LEDs of the Xserve G5 | ||
10 | * | ||
11 | * TODO: Implement PWM to do variable intensity and provide userland | ||
12 | * interface for fun. Also, the CPU-meter could be made nicer by being | ||
13 | * a bit less "immediate" but giving instead a more average load over | ||
14 | * time. Patches welcome :-) | ||
15 | * | ||
16 | */ | ||
17 | #undef DEBUG | ||
18 | |||
19 | #include <linux/types.h> | ||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/device.h> | ||
22 | #include <linux/interrupt.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/pci.h> | ||
25 | #include <linux/dma-mapping.h> | ||
26 | #include <linux/kernel_stat.h> | ||
27 | |||
28 | #include <asm/io.h> | ||
29 | #include <asm/prom.h> | ||
30 | #include <asm/machdep.h> | ||
31 | #include <asm/pmac_feature.h> | ||
32 | #include <asm/dbdma.h> | ||
33 | #include <asm/dbdma.h> | ||
34 | #include <asm/macio.h> | ||
35 | #include <asm/keylargo.h> | ||
36 | |||
37 | /* Number of samples in a sample buffer */ | ||
38 | #define SAMPLE_COUNT 256 | ||
39 | |||
40 | /* CPU meter sampling rate in ms */ | ||
41 | #define CPU_SAMPLING_RATE 250 | ||
42 | |||
43 | struct rackmeter_dma { | ||
44 | struct dbdma_cmd cmd[4] ____cacheline_aligned; | ||
45 | u32 mark ____cacheline_aligned; | ||
46 | u32 buf1[SAMPLE_COUNT] ____cacheline_aligned; | ||
47 | u32 buf2[SAMPLE_COUNT] ____cacheline_aligned; | ||
48 | } ____cacheline_aligned; | ||
49 | |||
50 | struct rackmeter_cpu { | ||
51 | struct work_struct sniffer; | ||
52 | cputime64_t prev_wall; | ||
53 | cputime64_t prev_idle; | ||
54 | int zero; | ||
55 | } ____cacheline_aligned; | ||
56 | |||
57 | struct rackmeter { | ||
58 | struct macio_dev *mdev; | ||
59 | unsigned int irq; | ||
60 | struct device_node *i2s; | ||
61 | u8 *ubuf; | ||
62 | struct dbdma_regs __iomem *dma_regs; | ||
63 | void __iomem *i2s_regs; | ||
64 | dma_addr_t dma_buf_p; | ||
65 | struct rackmeter_dma *dma_buf_v; | ||
66 | int stale_irq; | ||
67 | struct rackmeter_cpu cpu[2]; | ||
68 | int paused; | ||
69 | struct mutex sem; | ||
70 | }; | ||
71 | |||
72 | /* To be set as a tunable */ | ||
73 | static int rackmeter_ignore_nice; | ||
74 | |||
75 | /* This GPIO is whacked by the OS X driver when initializing */ | ||
76 | #define RACKMETER_MAGIC_GPIO 0x78 | ||
77 | |||
78 | /* This is copied from cpufreq_ondemand, maybe we should put it in | ||
79 | * a common header somewhere | ||
80 | */ | ||
81 | static inline cputime64_t get_cpu_idle_time(unsigned int cpu) | ||
82 | { | ||
83 | cputime64_t retval; | ||
84 | |||
85 | retval = cputime64_add(kstat_cpu(cpu).cpustat.idle, | ||
86 | kstat_cpu(cpu).cpustat.iowait); | ||
87 | |||
88 | if (rackmeter_ignore_nice) | ||
89 | retval = cputime64_add(retval, kstat_cpu(cpu).cpustat.nice); | ||
90 | |||
91 | return retval; | ||
92 | } | ||
93 | |||
94 | static void rackmeter_setup_i2s(struct rackmeter *rm) | ||
95 | { | ||
96 | struct macio_chip *macio = rm->mdev->bus->chip; | ||
97 | |||
98 | /* First whack magic GPIO */ | ||
99 | pmac_call_feature(PMAC_FTR_WRITE_GPIO, NULL, RACKMETER_MAGIC_GPIO, 5); | ||
100 | |||
101 | |||
102 | /* Call feature code to enable the sound channel and the proper | ||
103 | * clock sources | ||
104 | */ | ||
105 | pmac_call_feature(PMAC_FTR_SOUND_CHIP_ENABLE, rm->i2s, 0, 1); | ||
106 | |||
107 | /* Power i2s and stop i2s clock. We whack MacIO FCRs directly for now. | ||
108 | * This is a bit racy, thus we should add new platform functions to | ||
109 | * handle that. snd-aoa needs that too | ||
110 | */ | ||
111 | MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_ENABLE); | ||
112 | MACIO_BIC(KEYLARGO_FCR1, KL1_I2S0_CLK_ENABLE_BIT); | ||
113 | (void)MACIO_IN32(KEYLARGO_FCR1); | ||
114 | udelay(10); | ||
115 | |||
116 | /* Then setup i2s. For now, we use the same magic value that | ||
117 | * the OS X driver seems to use. We might want to play around | ||
118 | * with the clock divisors later | ||
119 | */ | ||
120 | out_le32(rm->i2s_regs + 0x10, 0x01fa0000); | ||
121 | (void)in_le32(rm->i2s_regs + 0x10); | ||
122 | udelay(10); | ||
123 | |||
124 | /* Fully restart i2s*/ | ||
125 | MACIO_BIS(KEYLARGO_FCR1, KL1_I2S0_CELL_ENABLE | | ||
126 | KL1_I2S0_CLK_ENABLE_BIT); | ||
127 | (void)MACIO_IN32(KEYLARGO_FCR1); | ||
128 | udelay(10); | ||
129 | } | ||
130 | |||
131 | static void rackmeter_set_default_pattern(struct rackmeter *rm) | ||
132 | { | ||
133 | int i; | ||
134 | |||
135 | for (i = 0; i < 16; i++) { | ||
136 | if (i < 8) | ||
137 | rm->ubuf[i] = (i & 1) * 255; | ||
138 | else | ||
139 | rm->ubuf[i] = ((~i) & 1) * 255; | ||
140 | } | ||
141 | } | ||
142 | |||
143 | static void rackmeter_do_pause(struct rackmeter *rm, int pause) | ||
144 | { | ||
145 | struct rackmeter_dma *rdma = rm->dma_buf_v; | ||
146 | |||
147 | pr_debug("rackmeter: %s\n", pause ? "paused" : "started"); | ||
148 | |||
149 | rm->paused = pause; | ||
150 | if (pause) { | ||
151 | DBDMA_DO_STOP(rm->dma_regs); | ||
152 | return; | ||
153 | } | ||
154 | memset(rdma->buf1, 0, SAMPLE_COUNT & sizeof(u32)); | ||
155 | memset(rdma->buf2, 0, SAMPLE_COUNT & sizeof(u32)); | ||
156 | |||
157 | rm->dma_buf_v->mark = 0; | ||
158 | |||
159 | mb(); | ||
160 | out_le32(&rm->dma_regs->cmdptr_hi, 0); | ||
161 | out_le32(&rm->dma_regs->cmdptr, rm->dma_buf_p); | ||
162 | out_le32(&rm->dma_regs->control, (RUN << 16) | RUN); | ||
163 | } | ||
164 | |||
165 | static void rackmeter_setup_dbdma(struct rackmeter *rm) | ||
166 | { | ||
167 | struct rackmeter_dma *db = rm->dma_buf_v; | ||
168 | struct dbdma_cmd *cmd = db->cmd; | ||
169 | |||
170 | /* Make sure dbdma is reset */ | ||
171 | DBDMA_DO_RESET(rm->dma_regs); | ||
172 | |||
173 | pr_debug("rackmeter: mark offset=0x%lx\n", | ||
174 | offsetof(struct rackmeter_dma, mark)); | ||
175 | pr_debug("rackmeter: buf1 offset=0x%lx\n", | ||
176 | offsetof(struct rackmeter_dma, buf1)); | ||
177 | pr_debug("rackmeter: buf2 offset=0x%lx\n", | ||
178 | offsetof(struct rackmeter_dma, buf2)); | ||
179 | |||
180 | /* Prepare 4 dbdma commands for the 2 buffers */ | ||
181 | memset(cmd, 0, 4 * sizeof(struct dbdma_cmd)); | ||
182 | st_le16(&cmd->req_count, 4); | ||
183 | st_le16(&cmd->command, STORE_WORD | INTR_ALWAYS | KEY_SYSTEM); | ||
184 | st_le32(&cmd->phy_addr, rm->dma_buf_p + | ||
185 | offsetof(struct rackmeter_dma, mark)); | ||
186 | st_le32(&cmd->cmd_dep, 0x02000000); | ||
187 | cmd++; | ||
188 | |||
189 | st_le16(&cmd->req_count, SAMPLE_COUNT * 4); | ||
190 | st_le16(&cmd->command, OUTPUT_MORE); | ||
191 | st_le32(&cmd->phy_addr, rm->dma_buf_p + | ||
192 | offsetof(struct rackmeter_dma, buf1)); | ||
193 | cmd++; | ||
194 | |||
195 | st_le16(&cmd->req_count, 4); | ||
196 | st_le16(&cmd->command, STORE_WORD | INTR_ALWAYS | KEY_SYSTEM); | ||
197 | st_le32(&cmd->phy_addr, rm->dma_buf_p + | ||
198 | offsetof(struct rackmeter_dma, mark)); | ||
199 | st_le32(&cmd->cmd_dep, 0x01000000); | ||
200 | cmd++; | ||
201 | |||
202 | st_le16(&cmd->req_count, SAMPLE_COUNT * 4); | ||
203 | st_le16(&cmd->command, OUTPUT_MORE | BR_ALWAYS); | ||
204 | st_le32(&cmd->phy_addr, rm->dma_buf_p + | ||
205 | offsetof(struct rackmeter_dma, buf2)); | ||
206 | st_le32(&cmd->cmd_dep, rm->dma_buf_p); | ||
207 | |||
208 | rackmeter_do_pause(rm, 0); | ||
209 | } | ||
210 | |||
211 | static void rackmeter_do_timer(void *data) | ||
212 | { | ||
213 | struct rackmeter *rm = data; | ||
214 | unsigned int cpu = smp_processor_id(); | ||
215 | struct rackmeter_cpu *rcpu = &rm->cpu[cpu]; | ||
216 | cputime64_t cur_jiffies, total_idle_ticks; | ||
217 | unsigned int total_ticks, idle_ticks; | ||
218 | int i, offset, load, cumm, pause; | ||
219 | |||
220 | cur_jiffies = jiffies64_to_cputime64(get_jiffies_64()); | ||
221 | total_ticks = (unsigned int)cputime64_sub(cur_jiffies, | ||
222 | rcpu->prev_wall); | ||
223 | rcpu->prev_wall = cur_jiffies; | ||
224 | |||
225 | total_idle_ticks = get_cpu_idle_time(cpu); | ||
226 | idle_ticks = (unsigned int) cputime64_sub(total_idle_ticks, | ||
227 | rcpu->prev_idle); | ||
228 | rcpu->prev_idle = total_idle_ticks; | ||
229 | |||
230 | /* We do a very dumb calculation to update the LEDs for now, | ||
231 | * we'll do better once we have actual PWM implemented | ||
232 | */ | ||
233 | load = (9 * (total_ticks - idle_ticks)) / total_ticks; | ||
234 | |||
235 | offset = cpu << 3; | ||
236 | cumm = 0; | ||
237 | for (i = 0; i < 8; i++) { | ||
238 | u8 ub = (load > i) ? 0xff : 0; | ||
239 | rm->ubuf[i + offset] = ub; | ||
240 | cumm |= ub; | ||
241 | } | ||
242 | rcpu->zero = (cumm == 0); | ||
243 | |||
244 | /* Now check if LEDs are all 0, we can stop DMA */ | ||
245 | pause = (rm->cpu[0].zero && rm->cpu[1].zero); | ||
246 | if (pause != rm->paused) { | ||
247 | mutex_lock(&rm->sem); | ||
248 | pause = (rm->cpu[0].zero && rm->cpu[1].zero); | ||
249 | rackmeter_do_pause(rm, pause); | ||
250 | mutex_unlock(&rm->sem); | ||
251 | } | ||
252 | schedule_delayed_work_on(cpu, &rcpu->sniffer, | ||
253 | msecs_to_jiffies(CPU_SAMPLING_RATE)); | ||
254 | } | ||
255 | |||
256 | static void __devinit rackmeter_init_cpu_sniffer(struct rackmeter *rm) | ||
257 | { | ||
258 | unsigned int cpu; | ||
259 | |||
260 | /* This driver works only with 1 or 2 CPUs numbered 0 and 1, | ||
261 | * but that's really all we have on Apple Xserve. It doesn't | ||
262 | * play very nice with CPU hotplug neither but we don't do that | ||
263 | * on those machines yet | ||
264 | */ | ||
265 | |||
266 | INIT_WORK(&rm->cpu[0].sniffer, rackmeter_do_timer, rm); | ||
267 | INIT_WORK(&rm->cpu[1].sniffer, rackmeter_do_timer, rm); | ||
268 | |||
269 | for_each_online_cpu(cpu) { | ||
270 | struct rackmeter_cpu *rcpu; | ||
271 | |||
272 | if (cpu > 1) | ||
273 | continue; | ||
274 | rcpu = &rm->cpu[cpu];; | ||
275 | rcpu->prev_idle = get_cpu_idle_time(cpu); | ||
276 | rcpu->prev_wall = jiffies64_to_cputime64(get_jiffies_64()); | ||
277 | schedule_delayed_work_on(cpu, &rm->cpu[cpu].sniffer, | ||
278 | msecs_to_jiffies(CPU_SAMPLING_RATE)); | ||
279 | } | ||
280 | } | ||
281 | |||
282 | static void __devexit rackmeter_stop_cpu_sniffer(struct rackmeter *rm) | ||
283 | { | ||
284 | cancel_rearming_delayed_work(&rm->cpu[0].sniffer); | ||
285 | cancel_rearming_delayed_work(&rm->cpu[1].sniffer); | ||
286 | } | ||
287 | |||
288 | static int rackmeter_setup(struct rackmeter *rm) | ||
289 | { | ||
290 | pr_debug("rackmeter: setting up i2s..\n"); | ||
291 | rackmeter_setup_i2s(rm); | ||
292 | |||
293 | pr_debug("rackmeter: setting up default pattern..\n"); | ||
294 | rackmeter_set_default_pattern(rm); | ||
295 | |||
296 | pr_debug("rackmeter: setting up dbdma..\n"); | ||
297 | rackmeter_setup_dbdma(rm); | ||
298 | |||
299 | pr_debug("rackmeter: start CPU measurements..\n"); | ||
300 | rackmeter_init_cpu_sniffer(rm); | ||
301 | |||
302 | printk(KERN_INFO "RackMeter initialized\n"); | ||
303 | |||
304 | return 0; | ||
305 | } | ||
306 | |||
307 | /* XXX FIXME: No PWM yet, this is 0/1 */ | ||
308 | static u32 rackmeter_calc_sample(struct rackmeter *rm, unsigned int index) | ||
309 | { | ||
310 | int led; | ||
311 | u32 sample = 0; | ||
312 | |||
313 | for (led = 0; led < 16; led++) { | ||
314 | sample >>= 1; | ||
315 | sample |= ((rm->ubuf[led] >= 0x80) << 15); | ||
316 | } | ||
317 | return (sample << 17) | (sample >> 15); | ||
318 | } | ||
319 | |||
320 | static irqreturn_t rackmeter_irq(int irq, void *arg) | ||
321 | { | ||
322 | struct rackmeter *rm = arg; | ||
323 | struct rackmeter_dma *db = rm->dma_buf_v; | ||
324 | unsigned int mark, i; | ||
325 | u32 *buf; | ||
326 | |||
327 | /* Flush PCI buffers with an MMIO read. Maybe we could actually | ||
328 | * check the status one day ... in case things go wrong, though | ||
329 | * this never happened to me | ||
330 | */ | ||
331 | (void)in_le32(&rm->dma_regs->status); | ||
332 | |||
333 | /* Make sure the CPU gets us in order */ | ||
334 | rmb(); | ||
335 | |||
336 | /* Read mark */ | ||
337 | mark = db->mark; | ||
338 | if (mark != 1 && mark != 2) { | ||
339 | printk(KERN_WARNING "rackmeter: Incorrect DMA mark 0x%08x\n", | ||
340 | mark); | ||
341 | /* We allow for 3 errors like that (stale DBDMA irqs) */ | ||
342 | if (++rm->stale_irq > 3) { | ||
343 | printk(KERN_ERR "rackmeter: Too many errors," | ||
344 | " stopping DMA\n"); | ||
345 | DBDMA_DO_RESET(rm->dma_regs); | ||
346 | } | ||
347 | return IRQ_HANDLED; | ||
348 | } | ||
349 | |||
350 | /* Next buffer we need to fill is mark value */ | ||
351 | buf = mark == 1 ? db->buf1 : db->buf2; | ||
352 | |||
353 | /* Fill it now. This routine converts the 8 bits depth sample array | ||
354 | * into the PWM bitmap for each LED. | ||
355 | */ | ||
356 | for (i = 0; i < SAMPLE_COUNT; i++) | ||
357 | buf[i] = rackmeter_calc_sample(rm, i); | ||
358 | |||
359 | |||
360 | return IRQ_HANDLED; | ||
361 | } | ||
362 | |||
363 | static int __devinit rackmeter_probe(struct macio_dev* mdev, | ||
364 | const struct of_device_id *match) | ||
365 | { | ||
366 | struct device_node *i2s = NULL, *np = NULL; | ||
367 | struct rackmeter *rm = NULL; | ||
368 | struct resource ri2s, rdma; | ||
369 | int rc = -ENODEV; | ||
370 | |||
371 | pr_debug("rackmeter_probe()\n"); | ||
372 | |||
373 | /* Get i2s-a node */ | ||
374 | while ((i2s = of_get_next_child(mdev->ofdev.node, i2s)) != NULL) | ||
375 | if (strcmp(i2s->name, "i2s-a") == 0) | ||
376 | break; | ||
377 | if (i2s == NULL) { | ||
378 | pr_debug(" i2s-a child not found\n"); | ||
379 | goto bail; | ||
380 | } | ||
381 | /* Get lightshow or virtual sound */ | ||
382 | while ((np = of_get_next_child(i2s, np)) != NULL) { | ||
383 | if (strcmp(np->name, "lightshow") == 0) | ||
384 | break; | ||
385 | if ((strcmp(np->name, "sound") == 0) && | ||
386 | get_property(np, "virtual", NULL) != NULL) | ||
387 | break; | ||
388 | } | ||
389 | if (np == NULL) { | ||
390 | pr_debug(" lightshow or sound+virtual child not found\n"); | ||
391 | goto bail; | ||
392 | } | ||
393 | |||
394 | /* Create and initialize our instance data */ | ||
395 | rm = kzalloc(sizeof(struct rackmeter), GFP_KERNEL); | ||
396 | if (rm == NULL) { | ||
397 | printk(KERN_ERR "rackmeter: failed to allocate memory !\n"); | ||
398 | rc = -ENOMEM; | ||
399 | goto bail_release; | ||
400 | } | ||
401 | rm->mdev = mdev; | ||
402 | rm->i2s = i2s; | ||
403 | mutex_init(&rm->sem); | ||
404 | dev_set_drvdata(&mdev->ofdev.dev, rm); | ||
405 | /* Check resources availability. We need at least resource 0 and 1 */ | ||
406 | #if 0 /* Use that when i2s-a is finally an mdev per-se */ | ||
407 | if (macio_resource_count(mdev) < 2 || macio_irq_count(mdev) < 2) { | ||
408 | printk(KERN_ERR | ||
409 | "rackmeter: found match but lacks resources: %s" | ||
410 | " (%d resources, %d interrupts)\n", | ||
411 | mdev->ofdev.node->full_name); | ||
412 | rc = -ENXIO; | ||
413 | goto bail_free; | ||
414 | } | ||
415 | if (macio_request_resources(mdev, "rackmeter")) { | ||
416 | printk(KERN_ERR | ||
417 | "rackmeter: failed to request resources: %s\n", | ||
418 | mdev->ofdev.node->full_name); | ||
419 | rc = -EBUSY; | ||
420 | goto bail_free; | ||
421 | } | ||
422 | rm->irq = macio_irq(mdev, 1); | ||
423 | #else | ||
424 | rm->irq = irq_of_parse_and_map(i2s, 1); | ||
425 | if (rm->irq == NO_IRQ || | ||
426 | of_address_to_resource(i2s, 0, &ri2s) || | ||
427 | of_address_to_resource(i2s, 1, &rdma)) { | ||
428 | printk(KERN_ERR | ||
429 | "rackmeter: found match but lacks resources: %s", | ||
430 | mdev->ofdev.node->full_name); | ||
431 | rc = -ENXIO; | ||
432 | goto bail_free; | ||
433 | } | ||
434 | #endif | ||
435 | |||
436 | pr_debug(" i2s @0x%08x\n", (unsigned int)ri2s.start); | ||
437 | pr_debug(" dma @0x%08x\n", (unsigned int)rdma.start); | ||
438 | pr_debug(" irq %d\n", rm->irq); | ||
439 | |||
440 | rm->ubuf = (u8 *)__get_free_page(GFP_KERNEL); | ||
441 | if (rm->ubuf == NULL) { | ||
442 | printk(KERN_ERR | ||
443 | "rackmeter: failed to allocate samples page !\n"); | ||
444 | rc = -ENOMEM; | ||
445 | goto bail_release; | ||
446 | } | ||
447 | |||
448 | rm->dma_buf_v = dma_alloc_coherent(&macio_get_pci_dev(mdev)->dev, | ||
449 | sizeof(struct rackmeter_dma), | ||
450 | &rm->dma_buf_p, GFP_KERNEL); | ||
451 | if (rm->dma_buf_v == NULL) { | ||
452 | printk(KERN_ERR | ||
453 | "rackmeter: failed to allocate dma buffer !\n"); | ||
454 | rc = -ENOMEM; | ||
455 | goto bail_free_samples; | ||
456 | } | ||
457 | #if 0 | ||
458 | rm->i2s_regs = ioremap(macio_resource_start(mdev, 0), 0x1000); | ||
459 | #else | ||
460 | rm->i2s_regs = ioremap(ri2s.start, 0x1000); | ||
461 | #endif | ||
462 | if (rm->i2s_regs == NULL) { | ||
463 | printk(KERN_ERR | ||
464 | "rackmeter: failed to map i2s registers !\n"); | ||
465 | rc = -ENXIO; | ||
466 | goto bail_free_dma; | ||
467 | } | ||
468 | #if 0 | ||
469 | rm->dma_regs = ioremap(macio_resource_start(mdev, 1), 0x100); | ||
470 | #else | ||
471 | rm->dma_regs = ioremap(rdma.start, 0x100); | ||
472 | #endif | ||
473 | if (rm->dma_regs == NULL) { | ||
474 | printk(KERN_ERR | ||
475 | "rackmeter: failed to map dma registers !\n"); | ||
476 | rc = -ENXIO; | ||
477 | goto bail_unmap_i2s; | ||
478 | } | ||
479 | |||
480 | rc = rackmeter_setup(rm); | ||
481 | if (rc) { | ||
482 | printk(KERN_ERR | ||
483 | "rackmeter: failed to initialize !\n"); | ||
484 | rc = -ENXIO; | ||
485 | goto bail_unmap_dma; | ||
486 | } | ||
487 | |||
488 | rc = request_irq(rm->irq, rackmeter_irq, 0, "rackmeter", rm); | ||
489 | if (rc != 0) { | ||
490 | printk(KERN_ERR | ||
491 | "rackmeter: failed to request interrupt !\n"); | ||
492 | goto bail_stop_dma; | ||
493 | } | ||
494 | of_node_put(np); | ||
495 | return 0; | ||
496 | |||
497 | bail_stop_dma: | ||
498 | DBDMA_DO_RESET(rm->dma_regs); | ||
499 | bail_unmap_dma: | ||
500 | iounmap(rm->dma_regs); | ||
501 | bail_unmap_i2s: | ||
502 | iounmap(rm->i2s_regs); | ||
503 | bail_free_dma: | ||
504 | dma_free_coherent(&macio_get_pci_dev(mdev)->dev, | ||
505 | sizeof(struct rackmeter_dma), | ||
506 | rm->dma_buf_v, rm->dma_buf_p); | ||
507 | bail_free_samples: | ||
508 | free_page((unsigned long)rm->ubuf); | ||
509 | bail_release: | ||
510 | #if 0 | ||
511 | macio_release_resources(mdev); | ||
512 | #endif | ||
513 | bail_free: | ||
514 | kfree(rm); | ||
515 | bail: | ||
516 | of_node_put(i2s); | ||
517 | of_node_put(np); | ||
518 | dev_set_drvdata(&mdev->ofdev.dev, NULL); | ||
519 | return rc; | ||
520 | } | ||
521 | |||
522 | static int __devexit rackmeter_remove(struct macio_dev* mdev) | ||
523 | { | ||
524 | struct rackmeter *rm = dev_get_drvdata(&mdev->ofdev.dev); | ||
525 | |||
526 | /* Stop CPU sniffer timer & work queues */ | ||
527 | rackmeter_stop_cpu_sniffer(rm); | ||
528 | |||
529 | /* Clear reference to private data */ | ||
530 | dev_set_drvdata(&mdev->ofdev.dev, NULL); | ||
531 | |||
532 | /* Stop/reset dbdma */ | ||
533 | DBDMA_DO_RESET(rm->dma_regs); | ||
534 | |||
535 | /* Release the IRQ */ | ||
536 | free_irq(rm->irq, rm); | ||
537 | |||
538 | /* Unmap registers */ | ||
539 | iounmap(rm->dma_regs); | ||
540 | iounmap(rm->i2s_regs); | ||
541 | |||
542 | /* Free DMA */ | ||
543 | dma_free_coherent(&macio_get_pci_dev(mdev)->dev, | ||
544 | sizeof(struct rackmeter_dma), | ||
545 | rm->dma_buf_v, rm->dma_buf_p); | ||
546 | |||
547 | /* Free samples */ | ||
548 | free_page((unsigned long)rm->ubuf); | ||
549 | |||
550 | #if 0 | ||
551 | /* Release resources */ | ||
552 | macio_release_resources(mdev); | ||
553 | #endif | ||
554 | |||
555 | /* Get rid of me */ | ||
556 | kfree(rm); | ||
557 | |||
558 | return 0; | ||
559 | } | ||
560 | |||
561 | static int rackmeter_shutdown(struct macio_dev* mdev) | ||
562 | { | ||
563 | struct rackmeter *rm = dev_get_drvdata(&mdev->ofdev.dev); | ||
564 | |||
565 | if (rm == NULL) | ||
566 | return -ENODEV; | ||
567 | |||
568 | /* Stop CPU sniffer timer & work queues */ | ||
569 | rackmeter_stop_cpu_sniffer(rm); | ||
570 | |||
571 | /* Stop/reset dbdma */ | ||
572 | DBDMA_DO_RESET(rm->dma_regs); | ||
573 | |||
574 | return 0; | ||
575 | } | ||
576 | |||
577 | static struct of_device_id rackmeter_match[] = { | ||
578 | { .name = "i2s" }, | ||
579 | { } | ||
580 | }; | ||
581 | |||
582 | static struct macio_driver rackmeter_drv = { | ||
583 | .name = "rackmeter", | ||
584 | .owner = THIS_MODULE, | ||
585 | .match_table = rackmeter_match, | ||
586 | .probe = rackmeter_probe, | ||
587 | .remove = rackmeter_remove, | ||
588 | .shutdown = rackmeter_shutdown, | ||
589 | }; | ||
590 | |||
591 | |||
592 | static int __init rackmeter_init(void) | ||
593 | { | ||
594 | pr_debug("rackmeter_init()\n"); | ||
595 | |||
596 | return macio_register_driver(&rackmeter_drv); | ||
597 | } | ||
598 | |||
599 | static void __exit rackmeter_exit(void) | ||
600 | { | ||
601 | pr_debug("rackmeter_exit()\n"); | ||
602 | |||
603 | macio_unregister_driver(&rackmeter_drv); | ||
604 | } | ||
605 | |||
606 | module_init(rackmeter_init); | ||
607 | module_exit(rackmeter_exit); | ||
608 | |||
609 | |||
610 | MODULE_LICENSE("GPL"); | ||
611 | MODULE_AUTHOR("Benjamin Herrenschmidt <benh@kernel.crashing.org>"); | ||
612 | MODULE_DESCRIPTION("RackMeter: Support vu-meter on XServe front panel"); | ||
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c index ade25b3fbb3..4f724cdd2ef 100644 --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <asm/abs_addr.h> | 46 | #include <asm/abs_addr.h> |
47 | #include <asm/uaccess.h> | 47 | #include <asm/uaccess.h> |
48 | #include <asm/of_device.h> | 48 | #include <asm/of_device.h> |
49 | #include <asm/of_platform.h> | ||
49 | 50 | ||
50 | #define VERSION "0.7" | 51 | #define VERSION "0.7" |
51 | #define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp." | 52 | #define AUTHOR "(c) 2005 Benjamin Herrenschmidt, IBM Corp." |
@@ -653,7 +654,7 @@ static int __init smu_init_sysfs(void) | |||
653 | * I'm a bit too far from figuring out how that works with those | 654 | * I'm a bit too far from figuring out how that works with those |
654 | * new chipsets, but that will come back and bite us | 655 | * new chipsets, but that will come back and bite us |
655 | */ | 656 | */ |
656 | of_register_driver(&smu_of_platform_driver); | 657 | of_register_platform_driver(&smu_of_platform_driver); |
657 | return 0; | 658 | return 0; |
658 | } | 659 | } |
659 | 660 | ||
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c index a0f30d0853e..13b953ae8eb 100644 --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <asm/io.h> | 30 | #include <asm/io.h> |
31 | #include <asm/system.h> | 31 | #include <asm/system.h> |
32 | #include <asm/sections.h> | 32 | #include <asm/sections.h> |
33 | #include <asm/of_device.h> | 33 | #include <asm/of_platform.h> |
34 | 34 | ||
35 | #undef DEBUG | 35 | #undef DEBUG |
36 | 36 | ||
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c index d00c0c37a12..2e4ad44a863 100644 --- a/drivers/macintosh/therm_pm72.c +++ b/drivers/macintosh/therm_pm72.c | |||
@@ -129,6 +129,7 @@ | |||
129 | #include <asm/sections.h> | 129 | #include <asm/sections.h> |
130 | #include <asm/of_device.h> | 130 | #include <asm/of_device.h> |
131 | #include <asm/macio.h> | 131 | #include <asm/macio.h> |
132 | #include <asm/of_platform.h> | ||
132 | 133 | ||
133 | #include "therm_pm72.h" | 134 | #include "therm_pm72.h" |
134 | 135 | ||
@@ -2236,14 +2237,14 @@ static int __init therm_pm72_init(void) | |||
2236 | return -ENODEV; | 2237 | return -ENODEV; |
2237 | } | 2238 | } |
2238 | 2239 | ||
2239 | of_register_driver(&fcu_of_platform_driver); | 2240 | of_register_platform_driver(&fcu_of_platform_driver); |
2240 | 2241 | ||
2241 | return 0; | 2242 | return 0; |
2242 | } | 2243 | } |
2243 | 2244 | ||
2244 | static void __exit therm_pm72_exit(void) | 2245 | static void __exit therm_pm72_exit(void) |
2245 | { | 2246 | { |
2246 | of_unregister_driver(&fcu_of_platform_driver); | 2247 | of_unregister_platform_driver(&fcu_of_platform_driver); |
2247 | 2248 | ||
2248 | if (of_dev) | 2249 | if (of_dev) |
2249 | of_device_unregister(of_dev); | 2250 | of_device_unregister(of_dev); |
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c index 738faab1b22..a1d3a987cb3 100644 --- a/drivers/macintosh/therm_windtunnel.c +++ b/drivers/macintosh/therm_windtunnel.c | |||
@@ -36,12 +36,13 @@ | |||
36 | #include <linux/i2c.h> | 36 | #include <linux/i2c.h> |
37 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
38 | #include <linux/init.h> | 38 | #include <linux/init.h> |
39 | |||
39 | #include <asm/prom.h> | 40 | #include <asm/prom.h> |
40 | #include <asm/machdep.h> | 41 | #include <asm/machdep.h> |
41 | #include <asm/io.h> | 42 | #include <asm/io.h> |
42 | #include <asm/system.h> | 43 | #include <asm/system.h> |
43 | #include <asm/sections.h> | 44 | #include <asm/sections.h> |
44 | #include <asm/of_device.h> | 45 | #include <asm/of_platform.h> |
45 | #include <asm/macio.h> | 46 | #include <asm/macio.h> |
46 | 47 | ||
47 | #define LOG_TEMP 0 /* continously log temperature */ | 48 | #define LOG_TEMP 0 /* continously log temperature */ |
@@ -511,14 +512,14 @@ g4fan_init( void ) | |||
511 | return -ENODEV; | 512 | return -ENODEV; |
512 | } | 513 | } |
513 | 514 | ||
514 | of_register_driver( &therm_of_driver ); | 515 | of_register_platform_driver( &therm_of_driver ); |
515 | return 0; | 516 | return 0; |
516 | } | 517 | } |
517 | 518 | ||
518 | static void __exit | 519 | static void __exit |
519 | g4fan_exit( void ) | 520 | g4fan_exit( void ) |
520 | { | 521 | { |
521 | of_unregister_driver( &therm_of_driver ); | 522 | of_unregister_platform_driver( &therm_of_driver ); |
522 | 523 | ||
523 | if( x.of_dev ) | 524 | if( x.of_dev ) |
524 | of_device_unregister( x.of_dev ); | 525 | of_device_unregister( x.of_dev ); |
diff --git a/drivers/net/ibm_emac/ibm_emac_mal.h b/drivers/net/ibm_emac/ibm_emac_mal.h index f73f10a0a56..407d2acbf7c 100644 --- a/drivers/net/ibm_emac/ibm_emac_mal.h +++ b/drivers/net/ibm_emac/ibm_emac_mal.h | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/netdevice.h> | 24 | #include <linux/netdevice.h> |
25 | 25 | ||
26 | #include <asm/io.h> | 26 | #include <asm/io.h> |
27 | #include <asm/dcr.h> | ||
27 | 28 | ||
28 | /* | 29 | /* |
29 | * These MAL "versions" probably aren't the real versions IBM uses for these | 30 | * These MAL "versions" probably aren't the real versions IBM uses for these |
@@ -191,6 +192,7 @@ struct mal_commac { | |||
191 | 192 | ||
192 | struct ibm_ocp_mal { | 193 | struct ibm_ocp_mal { |
193 | int dcrbase; | 194 | int dcrbase; |
195 | dcr_host_t dcrhost; | ||
194 | 196 | ||
195 | struct list_head poll_list; | 197 | struct list_head poll_list; |
196 | struct net_device poll_dev; | 198 | struct net_device poll_dev; |
@@ -207,12 +209,12 @@ struct ibm_ocp_mal { | |||
207 | 209 | ||
208 | static inline u32 get_mal_dcrn(struct ibm_ocp_mal *mal, int reg) | 210 | static inline u32 get_mal_dcrn(struct ibm_ocp_mal *mal, int reg) |
209 | { | 211 | { |
210 | return mfdcr(mal->dcrbase + reg); | 212 | return dcr_read(mal->dcrhost, mal->dcrbase + reg); |
211 | } | 213 | } |
212 | 214 | ||
213 | static inline void set_mal_dcrn(struct ibm_ocp_mal *mal, int reg, u32 val) | 215 | static inline void set_mal_dcrn(struct ibm_ocp_mal *mal, int reg, u32 val) |
214 | { | 216 | { |
215 | mtdcr(mal->dcrbase + reg, val); | 217 | dcr_write(mal->dcrhost, mal->dcrbase + reg, val); |
216 | } | 218 | } |
217 | 219 | ||
218 | /* Register MAL devices */ | 220 | /* Register MAL devices */ |
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c index 44c9f993dcc..99343b5836b 100644 --- a/drivers/net/ibmveth.c +++ b/drivers/net/ibmveth.c | |||
@@ -50,7 +50,6 @@ | |||
50 | #include <asm/semaphore.h> | 50 | #include <asm/semaphore.h> |
51 | #include <asm/hvcall.h> | 51 | #include <asm/hvcall.h> |
52 | #include <asm/atomic.h> | 52 | #include <asm/atomic.h> |
53 | #include <asm/iommu.h> | ||
54 | #include <asm/vio.h> | 53 | #include <asm/vio.h> |
55 | #include <asm/uaccess.h> | 54 | #include <asm/uaccess.h> |
56 | #include <linux/seq_file.h> | 55 | #include <linux/seq_file.h> |
@@ -1000,8 +999,6 @@ static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_ | |||
1000 | adapter->mac_addr = 0; | 999 | adapter->mac_addr = 0; |
1001 | memcpy(&adapter->mac_addr, mac_addr_p, 6); | 1000 | memcpy(&adapter->mac_addr, mac_addr_p, 6); |
1002 | 1001 | ||
1003 | adapter->liobn = dev->iommu_table->it_index; | ||
1004 | |||
1005 | netdev->irq = dev->irq; | 1002 | netdev->irq = dev->irq; |
1006 | netdev->open = ibmveth_open; | 1003 | netdev->open = ibmveth_open; |
1007 | netdev->poll = ibmveth_poll; | 1004 | netdev->poll = ibmveth_poll; |
@@ -1115,7 +1112,6 @@ static int ibmveth_seq_show(struct seq_file *seq, void *v) | |||
1115 | seq_printf(seq, "%s %s\n\n", ibmveth_driver_string, ibmveth_driver_version); | 1112 | seq_printf(seq, "%s %s\n\n", ibmveth_driver_string, ibmveth_driver_version); |
1116 | 1113 | ||
1117 | seq_printf(seq, "Unit Address: 0x%x\n", adapter->vdev->unit_address); | 1114 | seq_printf(seq, "Unit Address: 0x%x\n", adapter->vdev->unit_address); |
1118 | seq_printf(seq, "LIOBN: 0x%lx\n", adapter->liobn); | ||
1119 | seq_printf(seq, "Current MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", | 1115 | seq_printf(seq, "Current MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", |
1120 | current_mac[0], current_mac[1], current_mac[2], | 1116 | current_mac[0], current_mac[1], current_mac[2], |
1121 | current_mac[3], current_mac[4], current_mac[5]); | 1117 | current_mac[3], current_mac[4], current_mac[5]); |
diff --git a/drivers/net/ibmveth.h b/drivers/net/ibmveth.h index f5b25bff154..bb69ccae8ac 100644 --- a/drivers/net/ibmveth.h +++ b/drivers/net/ibmveth.h | |||
@@ -118,7 +118,6 @@ struct ibmveth_adapter { | |||
118 | struct net_device_stats stats; | 118 | struct net_device_stats stats; |
119 | unsigned int mcastFilterSize; | 119 | unsigned int mcastFilterSize; |
120 | unsigned long mac_addr; | 120 | unsigned long mac_addr; |
121 | unsigned long liobn; | ||
122 | void * buffer_list_addr; | 121 | void * buffer_list_addr; |
123 | void * filter_list_addr; | 122 | void * filter_list_addr; |
124 | dma_addr_t buffer_list_dma; | 123 | dma_addr_t buffer_list_dma; |
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c index f14e99276db..096d4a100bf 100644 --- a/drivers/net/phy/fixed.c +++ b/drivers/net/phy/fixed.c | |||
@@ -254,7 +254,7 @@ static int fixed_mdio_register_device(int number, int speed, int duplex) | |||
254 | goto device_create_fail; | 254 | goto device_create_fail; |
255 | } | 255 | } |
256 | 256 | ||
257 | phydev->irq = -1; | 257 | phydev->irq = PHY_IGNORE_INTERRUPT; |
258 | phydev->dev.bus = &mdio_bus_type; | 258 | phydev->dev.bus = &mdio_bus_type; |
259 | 259 | ||
260 | if(number) | 260 | if(number) |
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c index cef7e6671c4..13e0a43e423 100644 --- a/drivers/net/spider_net.c +++ b/drivers/net/spider_net.c | |||
@@ -88,12 +88,11 @@ MODULE_DEVICE_TABLE(pci, spider_net_pci_tbl); | |||
88 | static inline u32 | 88 | static inline u32 |
89 | spider_net_read_reg(struct spider_net_card *card, u32 reg) | 89 | spider_net_read_reg(struct spider_net_card *card, u32 reg) |
90 | { | 90 | { |
91 | u32 value; | 91 | /* We use the powerpc specific variants instead of readl_be() because |
92 | 92 | * we know spidernet is not a real PCI device and we can thus avoid the | |
93 | value = readl(card->regs + reg); | 93 | * performance hit caused by the PCI workarounds. |
94 | value = le32_to_cpu(value); | 94 | */ |
95 | 95 | return in_be32(card->regs + reg); | |
96 | return value; | ||
97 | } | 96 | } |
98 | 97 | ||
99 | /** | 98 | /** |
@@ -105,8 +104,11 @@ spider_net_read_reg(struct spider_net_card *card, u32 reg) | |||
105 | static inline void | 104 | static inline void |
106 | spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value) | 105 | spider_net_write_reg(struct spider_net_card *card, u32 reg, u32 value) |
107 | { | 106 | { |
108 | value = cpu_to_le32(value); | 107 | /* We use the powerpc specific variants instead of writel_be() because |
109 | writel(value, card->regs + reg); | 108 | * we know spidernet is not a real PCI device and we can thus avoid the |
109 | * performance hit caused by the PCI workarounds. | ||
110 | */ | ||
111 | out_be32(card->regs + reg, value); | ||
110 | } | 112 | } |
111 | 113 | ||
112 | /** spider_net_write_phy - write to phy register | 114 | /** spider_net_write_phy - write to phy register |
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c index 3f4b6408b75..4b3cd3d8b62 100644 --- a/drivers/net/tulip/de4x5.c +++ b/drivers/net/tulip/de4x5.c | |||
@@ -473,9 +473,9 @@ | |||
473 | #include <asm/byteorder.h> | 473 | #include <asm/byteorder.h> |
474 | #include <asm/unaligned.h> | 474 | #include <asm/unaligned.h> |
475 | #include <asm/uaccess.h> | 475 | #include <asm/uaccess.h> |
476 | #ifdef CONFIG_PPC_MULTIPLATFORM | 476 | #ifdef CONFIG_PPC_PMAC |
477 | #include <asm/machdep.h> | 477 | #include <asm/machdep.h> |
478 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | 478 | #endif /* CONFIG_PPC_PMAC */ |
479 | 479 | ||
480 | #include "de4x5.h" | 480 | #include "de4x5.h" |
481 | 481 | ||
@@ -4151,7 +4151,7 @@ get_hw_addr(struct net_device *dev) | |||
4151 | /* If possible, try to fix a broken card - SMC only so far */ | 4151 | /* If possible, try to fix a broken card - SMC only so far */ |
4152 | srom_repair(dev, broken); | 4152 | srom_repair(dev, broken); |
4153 | 4153 | ||
4154 | #ifdef CONFIG_PPC_MULTIPLATFORM | 4154 | #ifdef CONFIG_PPC_PMAC |
4155 | /* | 4155 | /* |
4156 | ** If the address starts with 00 a0, we have to bit-reverse | 4156 | ** If the address starts with 00 a0, we have to bit-reverse |
4157 | ** each byte of the address. | 4157 | ** each byte of the address. |
@@ -4168,7 +4168,7 @@ get_hw_addr(struct net_device *dev) | |||
4168 | dev->dev_addr[i] = ((x & 0x55) << 1) + ((x & 0xaa) >> 1); | 4168 | dev->dev_addr[i] = ((x & 0x55) << 1) + ((x & 0xaa) >> 1); |
4169 | } | 4169 | } |
4170 | } | 4170 | } |
4171 | #endif /* CONFIG_PPC_MULTIPLATFORM */ | 4171 | #endif /* CONFIG_PPC_PMAC */ |
4172 | 4172 | ||
4173 | /* Test for a bad enet address */ | 4173 | /* Test for a bad enet address */ |
4174 | status = test_bad_enet(dev, status); | 4174 | status = test_bad_enet(dev, status); |
diff --git a/drivers/ps3/Makefile b/drivers/ps3/Makefile new file mode 100644 index 00000000000..b52d547b7a7 --- /dev/null +++ b/drivers/ps3/Makefile | |||
@@ -0,0 +1 @@ | |||
obj-y += system-bus.o | |||
diff --git a/drivers/ps3/system-bus.c b/drivers/ps3/system-bus.c new file mode 100644 index 00000000000..d79f949bcb2 --- /dev/null +++ b/drivers/ps3/system-bus.c | |||
@@ -0,0 +1,362 @@ | |||
1 | /* | ||
2 | * PS3 system bus driver. | ||
3 | * | ||
4 | * Copyright (C) 2006 Sony Computer Entertainment Inc. | ||
5 | * Copyright 2006 Sony Corp. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; version 2 of the License. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/init.h> | ||
23 | #include <linux/module.h> | ||
24 | #include <linux/dma-mapping.h> | ||
25 | #include <linux/err.h> | ||
26 | |||
27 | #include <asm/udbg.h> | ||
28 | #include <asm/ps3.h> | ||
29 | #include <asm/lv1call.h> | ||
30 | #include <asm/firmware.h> | ||
31 | |||
32 | #define dump_mmio_region(_a) _dump_mmio_region(_a, __func__, __LINE__) | ||
33 | static void _dump_mmio_region(const struct ps3_mmio_region* r, | ||
34 | const char* func, int line) | ||
35 | { | ||
36 | pr_debug("%s:%d: dev %u:%u\n", func, line, r->did.bus_id, | ||
37 | r->did.dev_id); | ||
38 | pr_debug("%s:%d: bus_addr %lxh\n", func, line, r->bus_addr); | ||
39 | pr_debug("%s:%d: len %lxh\n", func, line, r->len); | ||
40 | pr_debug("%s:%d: lpar_addr %lxh\n", func, line, r->lpar_addr); | ||
41 | } | ||
42 | |||
43 | int ps3_mmio_region_create(struct ps3_mmio_region *r) | ||
44 | { | ||
45 | int result; | ||
46 | |||
47 | result = lv1_map_device_mmio_region(r->did.bus_id, r->did.dev_id, | ||
48 | r->bus_addr, r->len, r->page_size, &r->lpar_addr); | ||
49 | |||
50 | if (result) { | ||
51 | pr_debug("%s:%d: lv1_map_device_mmio_region failed: %s\n", | ||
52 | __func__, __LINE__, ps3_result(result)); | ||
53 | r->lpar_addr = r->len = r->bus_addr = 0; | ||
54 | } | ||
55 | |||
56 | dump_mmio_region(r); | ||
57 | return result; | ||
58 | } | ||
59 | |||
60 | int ps3_free_mmio_region(struct ps3_mmio_region *r) | ||
61 | { | ||
62 | int result; | ||
63 | |||
64 | result = lv1_unmap_device_mmio_region(r->did.bus_id, r->did.dev_id, | ||
65 | r->bus_addr); | ||
66 | |||
67 | if (result) | ||
68 | pr_debug("%s:%d: lv1_unmap_device_mmio_region failed: %s\n", | ||
69 | __func__, __LINE__, ps3_result(result)); | ||
70 | |||
71 | r->lpar_addr = r->len = r->bus_addr = 0; | ||
72 | return result; | ||
73 | } | ||
74 | |||
75 | static int ps3_system_bus_match(struct device *_dev, | ||
76 | struct device_driver *_drv) | ||
77 | { | ||
78 | int result; | ||
79 | struct ps3_system_bus_driver *drv = to_ps3_system_bus_driver(_drv); | ||
80 | struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev); | ||
81 | |||
82 | result = dev->match_id == drv->match_id; | ||
83 | |||
84 | pr_info("%s:%d: dev=%u(%s), drv=%u(%s): %s\n", __func__, __LINE__, | ||
85 | dev->match_id, dev->core.bus_id, drv->match_id, drv->core.name, | ||
86 | (result ? "match" : "miss")); | ||
87 | return result; | ||
88 | } | ||
89 | |||
90 | static int ps3_system_bus_probe(struct device *_dev) | ||
91 | { | ||
92 | int result; | ||
93 | struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev); | ||
94 | struct ps3_system_bus_driver *drv = | ||
95 | to_ps3_system_bus_driver(_dev->driver); | ||
96 | |||
97 | result = lv1_open_device(dev->did.bus_id, dev->did.dev_id, 0); | ||
98 | |||
99 | if (result) { | ||
100 | pr_debug("%s:%d: lv1_open_device failed (%d)\n", | ||
101 | __func__, __LINE__, result); | ||
102 | result = -EACCES; | ||
103 | goto clean_none; | ||
104 | } | ||
105 | |||
106 | if (dev->d_region->did.bus_id) { | ||
107 | result = ps3_dma_region_create(dev->d_region); | ||
108 | |||
109 | if (result) { | ||
110 | pr_debug("%s:%d: ps3_dma_region_create failed (%d)\n", | ||
111 | __func__, __LINE__, result); | ||
112 | BUG_ON("check region type"); | ||
113 | result = -EINVAL; | ||
114 | goto clean_device; | ||
115 | } | ||
116 | } | ||
117 | |||
118 | BUG_ON(!drv); | ||
119 | |||
120 | if (drv->probe) | ||
121 | result = drv->probe(dev); | ||
122 | else | ||
123 | pr_info("%s:%d: %s no probe method\n", __func__, __LINE__, | ||
124 | dev->core.bus_id); | ||
125 | |||
126 | if (result) { | ||
127 | pr_debug("%s:%d: drv->probe failed\n", __func__, __LINE__); | ||
128 | goto clean_dma; | ||
129 | } | ||
130 | |||
131 | return result; | ||
132 | |||
133 | clean_dma: | ||
134 | ps3_dma_region_free(dev->d_region); | ||
135 | clean_device: | ||
136 | lv1_close_device(dev->did.bus_id, dev->did.dev_id); | ||
137 | clean_none: | ||
138 | return result; | ||
139 | } | ||
140 | |||
141 | static int ps3_system_bus_remove(struct device *_dev) | ||
142 | { | ||
143 | struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev); | ||
144 | struct ps3_system_bus_driver *drv = | ||
145 | to_ps3_system_bus_driver(_dev->driver); | ||
146 | |||
147 | if (drv->remove) | ||
148 | drv->remove(dev); | ||
149 | else | ||
150 | pr_info("%s:%d: %s no remove method\n", __func__, __LINE__, | ||
151 | dev->core.bus_id); | ||
152 | |||
153 | ps3_dma_region_free(dev->d_region); | ||
154 | ps3_free_mmio_region(dev->m_region); | ||
155 | lv1_close_device(dev->did.bus_id, dev->did.dev_id); | ||
156 | |||
157 | return 0; | ||
158 | } | ||
159 | |||
160 | struct bus_type ps3_system_bus_type = { | ||
161 | .name = "ps3_system_bus", | ||
162 | .match = ps3_system_bus_match, | ||
163 | .probe = ps3_system_bus_probe, | ||
164 | .remove = ps3_system_bus_remove, | ||
165 | }; | ||
166 | |||
167 | int __init ps3_system_bus_init(void) | ||
168 | { | ||
169 | int result; | ||
170 | |||
171 | if (!firmware_has_feature(FW_FEATURE_PS3_LV1)) | ||
172 | return 0; | ||
173 | |||
174 | result = bus_register(&ps3_system_bus_type); | ||
175 | BUG_ON(result); | ||
176 | return result; | ||
177 | } | ||
178 | |||
179 | core_initcall(ps3_system_bus_init); | ||
180 | |||
181 | /* Allocates a contiguous real buffer and creates mappings over it. | ||
182 | * Returns the virtual address of the buffer and sets dma_handle | ||
183 | * to the dma address (mapping) of the first page. | ||
184 | */ | ||
185 | |||
186 | static void * ps3_alloc_coherent(struct device *_dev, size_t size, | ||
187 | dma_addr_t *dma_handle, gfp_t flag) | ||
188 | { | ||
189 | int result; | ||
190 | struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev); | ||
191 | unsigned long virt_addr; | ||
192 | |||
193 | BUG_ON(!dev->d_region->bus_addr); | ||
194 | |||
195 | flag &= ~(__GFP_DMA | __GFP_HIGHMEM); | ||
196 | flag |= __GFP_ZERO; | ||
197 | |||
198 | virt_addr = __get_free_pages(flag, get_order(size)); | ||
199 | |||
200 | if (!virt_addr) { | ||
201 | pr_debug("%s:%d: get_free_pages failed\n", __func__, __LINE__); | ||
202 | goto clean_none; | ||
203 | } | ||
204 | |||
205 | result = ps3_dma_map(dev->d_region, virt_addr, size, dma_handle); | ||
206 | |||
207 | if (result) { | ||
208 | pr_debug("%s:%d: ps3_dma_map failed (%d)\n", | ||
209 | __func__, __LINE__, result); | ||
210 | BUG_ON("check region type"); | ||
211 | goto clean_alloc; | ||
212 | } | ||
213 | |||
214 | return (void*)virt_addr; | ||
215 | |||
216 | clean_alloc: | ||
217 | free_pages(virt_addr, get_order(size)); | ||
218 | clean_none: | ||
219 | dma_handle = NULL; | ||
220 | return NULL; | ||
221 | } | ||
222 | |||
223 | static void ps3_free_coherent(struct device *_dev, size_t size, void *vaddr, | ||
224 | dma_addr_t dma_handle) | ||
225 | { | ||
226 | struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev); | ||
227 | |||
228 | ps3_dma_unmap(dev->d_region, dma_handle, size); | ||
229 | free_pages((unsigned long)vaddr, get_order(size)); | ||
230 | } | ||
231 | |||
232 | /* Creates TCEs for a user provided buffer. The user buffer must be | ||
233 | * contiguous real kernel storage (not vmalloc). The address of the buffer | ||
234 | * passed here is the kernel (virtual) address of the buffer. The buffer | ||
235 | * need not be page aligned, the dma_addr_t returned will point to the same | ||
236 | * byte within the page as vaddr. | ||
237 | */ | ||
238 | |||
239 | static dma_addr_t ps3_map_single(struct device *_dev, void *ptr, size_t size, | ||
240 | enum dma_data_direction direction) | ||
241 | { | ||
242 | struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev); | ||
243 | int result; | ||
244 | unsigned long bus_addr; | ||
245 | |||
246 | result = ps3_dma_map(dev->d_region, (unsigned long)ptr, size, | ||
247 | &bus_addr); | ||
248 | |||
249 | if (result) { | ||
250 | pr_debug("%s:%d: ps3_dma_map failed (%d)\n", | ||
251 | __func__, __LINE__, result); | ||
252 | } | ||
253 | |||
254 | return bus_addr; | ||
255 | } | ||
256 | |||
257 | static void ps3_unmap_single(struct device *_dev, dma_addr_t dma_addr, | ||
258 | size_t size, enum dma_data_direction direction) | ||
259 | { | ||
260 | struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev); | ||
261 | int result; | ||
262 | |||
263 | result = ps3_dma_unmap(dev->d_region, dma_addr, size); | ||
264 | |||
265 | if (result) { | ||
266 | pr_debug("%s:%d: ps3_dma_unmap failed (%d)\n", | ||
267 | __func__, __LINE__, result); | ||
268 | } | ||
269 | } | ||
270 | |||
271 | static int ps3_map_sg(struct device *_dev, struct scatterlist *sg, int nents, | ||
272 | enum dma_data_direction direction) | ||
273 | { | ||
274 | #if defined(CONFIG_PS3_DYNAMIC_DMA) | ||
275 | BUG_ON("do"); | ||
276 | #endif | ||
277 | return 0; | ||
278 | } | ||
279 | |||
280 | static void ps3_unmap_sg(struct device *_dev, struct scatterlist *sg, | ||
281 | int nents, enum dma_data_direction direction) | ||
282 | { | ||
283 | #if defined(CONFIG_PS3_DYNAMIC_DMA) | ||
284 | BUG_ON("do"); | ||
285 | #endif | ||
286 | } | ||
287 | |||
288 | static int ps3_dma_supported(struct device *_dev, u64 mask) | ||
289 | { | ||
290 | return 1; | ||
291 | } | ||
292 | |||
293 | static struct dma_mapping_ops ps3_dma_ops = { | ||
294 | .alloc_coherent = ps3_alloc_coherent, | ||
295 | .free_coherent = ps3_free_coherent, | ||
296 | .map_single = ps3_map_single, | ||
297 | .unmap_single = ps3_unmap_single, | ||
298 | .map_sg = ps3_map_sg, | ||
299 | .unmap_sg = ps3_unmap_sg, | ||
300 | .dma_supported = ps3_dma_supported | ||
301 | }; | ||
302 | |||
303 | /** | ||
304 | * ps3_system_bus_release_device - remove a device from the system bus | ||
305 | */ | ||
306 | |||
307 | static void ps3_system_bus_release_device(struct device *_dev) | ||
308 | { | ||
309 | struct ps3_system_bus_device *dev = to_ps3_system_bus_device(_dev); | ||
310 | kfree(dev); | ||
311 | } | ||
312 | |||
313 | /** | ||
314 | * ps3_system_bus_device_register - add a device to the system bus | ||
315 | * | ||
316 | * ps3_system_bus_device_register() expects the dev object to be allocated | ||
317 | * dynamically by the caller. The system bus takes ownership of the dev | ||
318 | * object and frees the object in ps3_system_bus_release_device(). | ||
319 | */ | ||
320 | |||
321 | int ps3_system_bus_device_register(struct ps3_system_bus_device *dev) | ||
322 | { | ||
323 | int result; | ||
324 | static unsigned int dev_count = 1; | ||
325 | |||
326 | dev->core.parent = NULL; | ||
327 | dev->core.bus = &ps3_system_bus_type; | ||
328 | dev->core.release = ps3_system_bus_release_device; | ||
329 | |||
330 | dev->core.archdata.of_node = NULL; | ||
331 | dev->core.archdata.dma_ops = &ps3_dma_ops; | ||
332 | dev->core.archdata.numa_node = 0; | ||
333 | |||
334 | snprintf(dev->core.bus_id, sizeof(dev->core.bus_id), "sb_%02x", | ||
335 | dev_count++); | ||
336 | |||
337 | pr_debug("%s:%d add %s\n", __func__, __LINE__, dev->core.bus_id); | ||
338 | |||
339 | result = device_register(&dev->core); | ||
340 | return result; | ||
341 | } | ||
342 | |||
343 | EXPORT_SYMBOL_GPL(ps3_system_bus_device_register); | ||
344 | |||
345 | int ps3_system_bus_driver_register(struct ps3_system_bus_driver *drv) | ||
346 | { | ||
347 | int result; | ||
348 | |||
349 | drv->core.bus = &ps3_system_bus_type; | ||
350 | |||
351 | result = driver_register(&drv->core); | ||
352 | return result; | ||
353 | } | ||
354 | |||
355 | EXPORT_SYMBOL_GPL(ps3_system_bus_driver_register); | ||
356 | |||
357 | void ps3_system_bus_driver_unregister(struct ps3_system_bus_driver *drv) | ||
358 | { | ||
359 | driver_unregister(&drv->core); | ||
360 | } | ||
361 | |||
362 | EXPORT_SYMBOL_GPL(ps3_system_bus_driver_unregister); | ||
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c index b691d3e1475..787a8f13467 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c +++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c | |||
@@ -282,7 +282,7 @@ void cpm_uart_freebuf(struct uart_cpm_port *pinfo) | |||
282 | } | 282 | } |
283 | 283 | ||
284 | /* Setup any dynamic params in the uart desc */ | 284 | /* Setup any dynamic params in the uart desc */ |
285 | int cpm_uart_init_portdesc(void) | 285 | int __init cpm_uart_init_portdesc(void) |
286 | { | 286 | { |
287 | #if defined(CONFIG_SERIAL_CPM_SMC1) || defined(CONFIG_SERIAL_CPM_SMC2) | 287 | #if defined(CONFIG_SERIAL_CPM_SMC1) || defined(CONFIG_SERIAL_CPM_SMC2) |
288 | u32 addr; | 288 | u32 addr; |
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c index 4f80c5b4a75..6dd579ed977 100644 --- a/drivers/serial/mpc52xx_uart.c +++ b/drivers/serial/mpc52xx_uart.c | |||
@@ -1,6 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/serial/mpc52xx_uart.c | ||
3 | * | ||
4 | * Driver for the PSC of the Freescale MPC52xx PSCs configured as UARTs. | 2 | * Driver for the PSC of the Freescale MPC52xx PSCs configured as UARTs. |
5 | * | 3 | * |
6 | * FIXME According to the usermanual the status bits in the status register | 4 | * FIXME According to the usermanual the status bits in the status register |
@@ -14,18 +12,20 @@ | |||
14 | * | 12 | * |
15 | * | 13 | * |
16 | * Maintainer : Sylvain Munaut <tnt@246tNt.com> | 14 | * Maintainer : Sylvain Munaut <tnt@246tNt.com> |
17 | * | 15 | * |
18 | * Some of the code has been inspired/copied from the 2.4 code written | 16 | * Some of the code has been inspired/copied from the 2.4 code written |
19 | * by Dale Farnsworth <dfarnsworth@mvista.com>. | 17 | * by Dale Farnsworth <dfarnsworth@mvista.com>. |
20 | * | 18 | * |
21 | * Copyright (C) 2004-2005 Sylvain Munaut <tnt@246tNt.com> | 19 | * Copyright (C) 2006 Secret Lab Technologies Ltd. |
20 | * Grant Likely <grant.likely@secretlab.ca> | ||
21 | * Copyright (C) 2004-2006 Sylvain Munaut <tnt@246tNt.com> | ||
22 | * Copyright (C) 2003 MontaVista, Software, Inc. | 22 | * Copyright (C) 2003 MontaVista, Software, Inc. |
23 | * | 23 | * |
24 | * This file is licensed under the terms of the GNU General Public License | 24 | * This file is licensed under the terms of the GNU General Public License |
25 | * version 2. This program is licensed "as is" without any warranty of any | 25 | * version 2. This program is licensed "as is" without any warranty of any |
26 | * kind, whether express or implied. | 26 | * kind, whether express or implied. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | /* Platform device Usage : | 29 | /* Platform device Usage : |
30 | * | 30 | * |
31 | * Since PSCs can have multiple function, the correct driver for each one | 31 | * Since PSCs can have multiple function, the correct driver for each one |
@@ -44,7 +44,24 @@ | |||
44 | * will be mapped to. | 44 | * will be mapped to. |
45 | */ | 45 | */ |
46 | 46 | ||
47 | #include <linux/platform_device.h> | 47 | /* OF Platform device Usage : |
48 | * | ||
49 | * This driver is only used for PSCs configured in uart mode. The device | ||
50 | * tree will have a node for each PSC in uart mode w/ device_type = "serial" | ||
51 | * and "mpc52xx-psc-uart" in the compatible string | ||
52 | * | ||
53 | * By default, PSC devices are enumerated in the order they are found. However | ||
54 | * a particular PSC number can be forces by adding 'device_no = <port#>' | ||
55 | * to the device node. | ||
56 | * | ||
57 | * The driver init all necessary registers to place the PSC in uart mode without | ||
58 | * DCD. However, the pin multiplexing aren't changed and should be set either | ||
59 | * by the bootloader or in the platform init code. | ||
60 | */ | ||
61 | |||
62 | #undef DEBUG | ||
63 | |||
64 | #include <linux/device.h> | ||
48 | #include <linux/module.h> | 65 | #include <linux/module.h> |
49 | #include <linux/tty.h> | 66 | #include <linux/tty.h> |
50 | #include <linux/serial.h> | 67 | #include <linux/serial.h> |
@@ -54,6 +71,12 @@ | |||
54 | #include <asm/delay.h> | 71 | #include <asm/delay.h> |
55 | #include <asm/io.h> | 72 | #include <asm/io.h> |
56 | 73 | ||
74 | #if defined(CONFIG_PPC_MERGE) | ||
75 | #include <asm/of_platform.h> | ||
76 | #else | ||
77 | #include <linux/platform_device.h> | ||
78 | #endif | ||
79 | |||
57 | #include <asm/mpc52xx.h> | 80 | #include <asm/mpc52xx.h> |
58 | #include <asm/mpc52xx_psc.h> | 81 | #include <asm/mpc52xx_psc.h> |
59 | 82 | ||
@@ -80,6 +103,12 @@ static struct uart_port mpc52xx_uart_ports[MPC52xx_PSC_MAXNUM]; | |||
80 | * it's cleared, then a memset(...,0,...) should be added to | 103 | * it's cleared, then a memset(...,0,...) should be added to |
81 | * the console_init | 104 | * the console_init |
82 | */ | 105 | */ |
106 | #if defined(CONFIG_PPC_MERGE) | ||
107 | /* lookup table for matching device nodes to index numbers */ | ||
108 | static struct device_node *mpc52xx_uart_nodes[MPC52xx_PSC_MAXNUM]; | ||
109 | |||
110 | static void mpc52xx_uart_of_enumerate(void); | ||
111 | #endif | ||
83 | 112 | ||
84 | #define PSC(port) ((struct mpc52xx_psc __iomem *)((port)->membase)) | 113 | #define PSC(port) ((struct mpc52xx_psc __iomem *)((port)->membase)) |
85 | 114 | ||
@@ -96,32 +125,40 @@ static irqreturn_t mpc52xx_uart_int(int irq,void *dev_id); | |||
96 | #define uart_console(port) (0) | 125 | #define uart_console(port) (0) |
97 | #endif | 126 | #endif |
98 | 127 | ||
128 | #if defined(CONFIG_PPC_MERGE) | ||
129 | static struct of_device_id mpc52xx_uart_of_match[] = { | ||
130 | { .type = "serial", .compatible = "mpc52xx-psc-uart", }, | ||
131 | { .type = "serial", .compatible = "mpc5200-psc", }, /* Efika only! */ | ||
132 | {}, | ||
133 | }; | ||
134 | #endif | ||
135 | |||
99 | 136 | ||
100 | /* ======================================================================== */ | 137 | /* ======================================================================== */ |
101 | /* UART operations */ | 138 | /* UART operations */ |
102 | /* ======================================================================== */ | 139 | /* ======================================================================== */ |
103 | 140 | ||
104 | static unsigned int | 141 | static unsigned int |
105 | mpc52xx_uart_tx_empty(struct uart_port *port) | 142 | mpc52xx_uart_tx_empty(struct uart_port *port) |
106 | { | 143 | { |
107 | int status = in_be16(&PSC(port)->mpc52xx_psc_status); | 144 | int status = in_be16(&PSC(port)->mpc52xx_psc_status); |
108 | return (status & MPC52xx_PSC_SR_TXEMP) ? TIOCSER_TEMT : 0; | 145 | return (status & MPC52xx_PSC_SR_TXEMP) ? TIOCSER_TEMT : 0; |
109 | } | 146 | } |
110 | 147 | ||
111 | static void | 148 | static void |
112 | mpc52xx_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) | 149 | mpc52xx_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) |
113 | { | 150 | { |
114 | /* Not implemented */ | 151 | /* Not implemented */ |
115 | } | 152 | } |
116 | 153 | ||
117 | static unsigned int | 154 | static unsigned int |
118 | mpc52xx_uart_get_mctrl(struct uart_port *port) | 155 | mpc52xx_uart_get_mctrl(struct uart_port *port) |
119 | { | 156 | { |
120 | /* Not implemented */ | 157 | /* Not implemented */ |
121 | return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR; | 158 | return TIOCM_CTS | TIOCM_DSR | TIOCM_CAR; |
122 | } | 159 | } |
123 | 160 | ||
124 | static void | 161 | static void |
125 | mpc52xx_uart_stop_tx(struct uart_port *port) | 162 | mpc52xx_uart_stop_tx(struct uart_port *port) |
126 | { | 163 | { |
127 | /* port->lock taken by caller */ | 164 | /* port->lock taken by caller */ |
@@ -129,7 +166,7 @@ mpc52xx_uart_stop_tx(struct uart_port *port) | |||
129 | out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); | 166 | out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); |
130 | } | 167 | } |
131 | 168 | ||
132 | static void | 169 | static void |
133 | mpc52xx_uart_start_tx(struct uart_port *port) | 170 | mpc52xx_uart_start_tx(struct uart_port *port) |
134 | { | 171 | { |
135 | /* port->lock taken by caller */ | 172 | /* port->lock taken by caller */ |
@@ -137,12 +174,12 @@ mpc52xx_uart_start_tx(struct uart_port *port) | |||
137 | out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); | 174 | out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); |
138 | } | 175 | } |
139 | 176 | ||
140 | static void | 177 | static void |
141 | mpc52xx_uart_send_xchar(struct uart_port *port, char ch) | 178 | mpc52xx_uart_send_xchar(struct uart_port *port, char ch) |
142 | { | 179 | { |
143 | unsigned long flags; | 180 | unsigned long flags; |
144 | spin_lock_irqsave(&port->lock, flags); | 181 | spin_lock_irqsave(&port->lock, flags); |
145 | 182 | ||
146 | port->x_char = ch; | 183 | port->x_char = ch; |
147 | if (ch) { | 184 | if (ch) { |
148 | /* Make sure tx interrupts are on */ | 185 | /* Make sure tx interrupts are on */ |
@@ -150,7 +187,7 @@ mpc52xx_uart_send_xchar(struct uart_port *port, char ch) | |||
150 | port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY; | 187 | port->read_status_mask |= MPC52xx_PSC_IMR_TXRDY; |
151 | out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); | 188 | out_be16(&PSC(port)->mpc52xx_psc_imr,port->read_status_mask); |
152 | } | 189 | } |
153 | 190 | ||
154 | spin_unlock_irqrestore(&port->lock, flags); | 191 | spin_unlock_irqrestore(&port->lock, flags); |
155 | } | 192 | } |
156 | 193 | ||
@@ -178,7 +215,7 @@ mpc52xx_uart_break_ctl(struct uart_port *port, int ctl) | |||
178 | out_8(&PSC(port)->command,MPC52xx_PSC_START_BRK); | 215 | out_8(&PSC(port)->command,MPC52xx_PSC_START_BRK); |
179 | else | 216 | else |
180 | out_8(&PSC(port)->command,MPC52xx_PSC_STOP_BRK); | 217 | out_8(&PSC(port)->command,MPC52xx_PSC_STOP_BRK); |
181 | 218 | ||
182 | spin_unlock_irqrestore(&port->lock, flags); | 219 | spin_unlock_irqrestore(&port->lock, flags); |
183 | } | 220 | } |
184 | 221 | ||
@@ -197,11 +234,11 @@ mpc52xx_uart_startup(struct uart_port *port) | |||
197 | /* Reset/activate the port, clear and enable interrupts */ | 234 | /* Reset/activate the port, clear and enable interrupts */ |
198 | out_8(&psc->command,MPC52xx_PSC_RST_RX); | 235 | out_8(&psc->command,MPC52xx_PSC_RST_RX); |
199 | out_8(&psc->command,MPC52xx_PSC_RST_TX); | 236 | out_8(&psc->command,MPC52xx_PSC_RST_TX); |
200 | 237 | ||
201 | out_be32(&psc->sicr,0); /* UART mode DCD ignored */ | 238 | out_be32(&psc->sicr,0); /* UART mode DCD ignored */ |
202 | 239 | ||
203 | out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00); /* /16 prescaler on */ | 240 | out_be16(&psc->mpc52xx_psc_clock_select, 0xdd00); /* /16 prescaler on */ |
204 | 241 | ||
205 | out_8(&psc->rfcntl, 0x00); | 242 | out_8(&psc->rfcntl, 0x00); |
206 | out_be16(&psc->rfalarm, 0x1ff); | 243 | out_be16(&psc->rfalarm, 0x1ff); |
207 | out_8(&psc->tfcntl, 0x07); | 244 | out_8(&psc->tfcntl, 0x07); |
@@ -209,10 +246,10 @@ mpc52xx_uart_startup(struct uart_port *port) | |||
209 | 246 | ||
210 | port->read_status_mask |= MPC52xx_PSC_IMR_RXRDY | MPC52xx_PSC_IMR_TXRDY; | 247 | port->read_status_mask |= MPC52xx_PSC_IMR_RXRDY | MPC52xx_PSC_IMR_TXRDY; |
211 | out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask); | 248 | out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask); |
212 | 249 | ||
213 | out_8(&psc->command,MPC52xx_PSC_TX_ENABLE); | 250 | out_8(&psc->command,MPC52xx_PSC_TX_ENABLE); |
214 | out_8(&psc->command,MPC52xx_PSC_RX_ENABLE); | 251 | out_8(&psc->command,MPC52xx_PSC_RX_ENABLE); |
215 | 252 | ||
216 | return 0; | 253 | return 0; |
217 | } | 254 | } |
218 | 255 | ||
@@ -220,19 +257,19 @@ static void | |||
220 | mpc52xx_uart_shutdown(struct uart_port *port) | 257 | mpc52xx_uart_shutdown(struct uart_port *port) |
221 | { | 258 | { |
222 | struct mpc52xx_psc __iomem *psc = PSC(port); | 259 | struct mpc52xx_psc __iomem *psc = PSC(port); |
223 | 260 | ||
224 | /* Shut down the port, interrupt and all */ | 261 | /* Shut down the port, interrupt and all */ |
225 | out_8(&psc->command,MPC52xx_PSC_RST_RX); | 262 | out_8(&psc->command,MPC52xx_PSC_RST_RX); |
226 | out_8(&psc->command,MPC52xx_PSC_RST_TX); | 263 | out_8(&psc->command,MPC52xx_PSC_RST_TX); |
227 | 264 | ||
228 | port->read_status_mask = 0; | 265 | port->read_status_mask = 0; |
229 | out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask); | 266 | out_be16(&psc->mpc52xx_psc_imr,port->read_status_mask); |
230 | 267 | ||
231 | /* Release interrupt */ | 268 | /* Release interrupt */ |
232 | free_irq(port->irq, port); | 269 | free_irq(port->irq, port); |
233 | } | 270 | } |
234 | 271 | ||
235 | static void | 272 | static void |
236 | mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new, | 273 | mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new, |
237 | struct termios *old) | 274 | struct termios *old) |
238 | { | 275 | { |
@@ -241,10 +278,10 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new, | |||
241 | unsigned char mr1, mr2; | 278 | unsigned char mr1, mr2; |
242 | unsigned short ctr; | 279 | unsigned short ctr; |
243 | unsigned int j, baud, quot; | 280 | unsigned int j, baud, quot; |
244 | 281 | ||
245 | /* Prepare what we're gonna write */ | 282 | /* Prepare what we're gonna write */ |
246 | mr1 = 0; | 283 | mr1 = 0; |
247 | 284 | ||
248 | switch (new->c_cflag & CSIZE) { | 285 | switch (new->c_cflag & CSIZE) { |
249 | case CS5: mr1 |= MPC52xx_PSC_MODE_5_BITS; | 286 | case CS5: mr1 |= MPC52xx_PSC_MODE_5_BITS; |
250 | break; | 287 | break; |
@@ -261,8 +298,8 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new, | |||
261 | MPC52xx_PSC_MODE_PARODD : MPC52xx_PSC_MODE_PAREVEN; | 298 | MPC52xx_PSC_MODE_PARODD : MPC52xx_PSC_MODE_PAREVEN; |
262 | } else | 299 | } else |
263 | mr1 |= MPC52xx_PSC_MODE_PARNONE; | 300 | mr1 |= MPC52xx_PSC_MODE_PARNONE; |
264 | 301 | ||
265 | 302 | ||
266 | mr2 = 0; | 303 | mr2 = 0; |
267 | 304 | ||
268 | if (new->c_cflag & CSTOPB) | 305 | if (new->c_cflag & CSTOPB) |
@@ -276,7 +313,7 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new, | |||
276 | baud = uart_get_baud_rate(port, new, old, 0, port->uartclk/16); | 313 | baud = uart_get_baud_rate(port, new, old, 0, port->uartclk/16); |
277 | quot = uart_get_divisor(port, baud); | 314 | quot = uart_get_divisor(port, baud); |
278 | ctr = quot & 0xffff; | 315 | ctr = quot & 0xffff; |
279 | 316 | ||
280 | /* Get the lock */ | 317 | /* Get the lock */ |
281 | spin_lock_irqsave(&port->lock, flags); | 318 | spin_lock_irqsave(&port->lock, flags); |
282 | 319 | ||
@@ -290,14 +327,14 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new, | |||
290 | * boot for the console, all stuff is not yet ready to receive at that | 327 | * boot for the console, all stuff is not yet ready to receive at that |
291 | * time and that just makes the kernel oops */ | 328 | * time and that just makes the kernel oops */ |
292 | /* while (j-- && mpc52xx_uart_int_rx_chars(port)); */ | 329 | /* while (j-- && mpc52xx_uart_int_rx_chars(port)); */ |
293 | while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP) && | 330 | while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP) && |
294 | --j) | 331 | --j) |
295 | udelay(1); | 332 | udelay(1); |
296 | 333 | ||
297 | if (!j) | 334 | if (!j) |
298 | printk( KERN_ERR "mpc52xx_uart.c: " | 335 | printk( KERN_ERR "mpc52xx_uart.c: " |
299 | "Unable to flush RX & TX fifos in-time in set_termios." | 336 | "Unable to flush RX & TX fifos in-time in set_termios." |
300 | "Some chars may have been lost.\n" ); | 337 | "Some chars may have been lost.\n" ); |
301 | 338 | ||
302 | /* Reset the TX & RX */ | 339 | /* Reset the TX & RX */ |
303 | out_8(&psc->command,MPC52xx_PSC_RST_RX); | 340 | out_8(&psc->command,MPC52xx_PSC_RST_RX); |
@@ -309,7 +346,7 @@ mpc52xx_uart_set_termios(struct uart_port *port, struct termios *new, | |||
309 | out_8(&psc->mode,mr2); | 346 | out_8(&psc->mode,mr2); |
310 | out_8(&psc->ctur,ctr >> 8); | 347 | out_8(&psc->ctur,ctr >> 8); |
311 | out_8(&psc->ctlr,ctr & 0xff); | 348 | out_8(&psc->ctlr,ctr & 0xff); |
312 | 349 | ||
313 | /* Reenable TX & RX */ | 350 | /* Reenable TX & RX */ |
314 | out_8(&psc->command,MPC52xx_PSC_TX_ENABLE); | 351 | out_8(&psc->command,MPC52xx_PSC_TX_ENABLE); |
315 | out_8(&psc->command,MPC52xx_PSC_RX_ENABLE); | 352 | out_8(&psc->command,MPC52xx_PSC_RX_ENABLE); |
@@ -332,7 +369,7 @@ mpc52xx_uart_release_port(struct uart_port *port) | |||
332 | port->membase = NULL; | 369 | port->membase = NULL; |
333 | } | 370 | } |
334 | 371 | ||
335 | release_mem_region(port->mapbase, MPC52xx_PSC_SIZE); | 372 | release_mem_region(port->mapbase, sizeof(struct mpc52xx_psc)); |
336 | } | 373 | } |
337 | 374 | ||
338 | static int | 375 | static int |
@@ -341,12 +378,13 @@ mpc52xx_uart_request_port(struct uart_port *port) | |||
341 | int err; | 378 | int err; |
342 | 379 | ||
343 | if (port->flags & UPF_IOREMAP) /* Need to remap ? */ | 380 | if (port->flags & UPF_IOREMAP) /* Need to remap ? */ |
344 | port->membase = ioremap(port->mapbase, MPC52xx_PSC_SIZE); | 381 | port->membase = ioremap(port->mapbase, |
382 | sizeof(struct mpc52xx_psc)); | ||
345 | 383 | ||
346 | if (!port->membase) | 384 | if (!port->membase) |
347 | return -EINVAL; | 385 | return -EINVAL; |
348 | 386 | ||
349 | err = request_mem_region(port->mapbase, MPC52xx_PSC_SIZE, | 387 | err = request_mem_region(port->mapbase, sizeof(struct mpc52xx_psc), |
350 | "mpc52xx_psc_uart") != NULL ? 0 : -EBUSY; | 388 | "mpc52xx_psc_uart") != NULL ? 0 : -EBUSY; |
351 | 389 | ||
352 | if (err && (port->flags & UPF_IOREMAP)) { | 390 | if (err && (port->flags & UPF_IOREMAP)) { |
@@ -373,7 +411,7 @@ mpc52xx_uart_verify_port(struct uart_port *port, struct serial_struct *ser) | |||
373 | 411 | ||
374 | if ( (ser->irq != port->irq) || | 412 | if ( (ser->irq != port->irq) || |
375 | (ser->io_type != SERIAL_IO_MEM) || | 413 | (ser->io_type != SERIAL_IO_MEM) || |
376 | (ser->baud_base != port->uartclk) || | 414 | (ser->baud_base != port->uartclk) || |
377 | (ser->iomem_base != (void*)port->mapbase) || | 415 | (ser->iomem_base != (void*)port->mapbase) || |
378 | (ser->hub6 != 0 ) ) | 416 | (ser->hub6 != 0 ) ) |
379 | return -EINVAL; | 417 | return -EINVAL; |
@@ -404,11 +442,11 @@ static struct uart_ops mpc52xx_uart_ops = { | |||
404 | .verify_port = mpc52xx_uart_verify_port | 442 | .verify_port = mpc52xx_uart_verify_port |
405 | }; | 443 | }; |
406 | 444 | ||
407 | 445 | ||
408 | /* ======================================================================== */ | 446 | /* ======================================================================== */ |
409 | /* Interrupt handling */ | 447 | /* Interrupt handling */ |
410 | /* ======================================================================== */ | 448 | /* ======================================================================== */ |
411 | 449 | ||
412 | static inline int | 450 | static inline int |
413 | mpc52xx_uart_int_rx_chars(struct uart_port *port) | 451 | mpc52xx_uart_int_rx_chars(struct uart_port *port) |
414 | { | 452 | { |
@@ -435,11 +473,11 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port) | |||
435 | 473 | ||
436 | flag = TTY_NORMAL; | 474 | flag = TTY_NORMAL; |
437 | port->icount.rx++; | 475 | port->icount.rx++; |
438 | 476 | ||
439 | if ( status & (MPC52xx_PSC_SR_PE | | 477 | if ( status & (MPC52xx_PSC_SR_PE | |
440 | MPC52xx_PSC_SR_FE | | 478 | MPC52xx_PSC_SR_FE | |
441 | MPC52xx_PSC_SR_RB) ) { | 479 | MPC52xx_PSC_SR_RB) ) { |
442 | 480 | ||
443 | if (status & MPC52xx_PSC_SR_RB) { | 481 | if (status & MPC52xx_PSC_SR_RB) { |
444 | flag = TTY_BREAK; | 482 | flag = TTY_BREAK; |
445 | uart_handle_break(port); | 483 | uart_handle_break(port); |
@@ -464,7 +502,7 @@ mpc52xx_uart_int_rx_chars(struct uart_port *port) | |||
464 | } | 502 | } |
465 | 503 | ||
466 | tty_flip_buffer_push(tty); | 504 | tty_flip_buffer_push(tty); |
467 | 505 | ||
468 | return in_be16(&PSC(port)->mpc52xx_psc_status) & MPC52xx_PSC_SR_RXRDY; | 506 | return in_be16(&PSC(port)->mpc52xx_psc_status) & MPC52xx_PSC_SR_RXRDY; |
469 | } | 507 | } |
470 | 508 | ||
@@ -509,25 +547,25 @@ mpc52xx_uart_int_tx_chars(struct uart_port *port) | |||
509 | return 1; | 547 | return 1; |
510 | } | 548 | } |
511 | 549 | ||
512 | static irqreturn_t | 550 | static irqreturn_t |
513 | mpc52xx_uart_int(int irq, void *dev_id) | 551 | mpc52xx_uart_int(int irq, void *dev_id) |
514 | { | 552 | { |
515 | struct uart_port *port = dev_id; | 553 | struct uart_port *port = dev_id; |
516 | unsigned long pass = ISR_PASS_LIMIT; | 554 | unsigned long pass = ISR_PASS_LIMIT; |
517 | unsigned int keepgoing; | 555 | unsigned int keepgoing; |
518 | unsigned short status; | 556 | unsigned short status; |
519 | 557 | ||
520 | spin_lock(&port->lock); | 558 | spin_lock(&port->lock); |
521 | 559 | ||
522 | /* While we have stuff to do, we continue */ | 560 | /* While we have stuff to do, we continue */ |
523 | do { | 561 | do { |
524 | /* If we don't find anything to do, we stop */ | 562 | /* If we don't find anything to do, we stop */ |
525 | keepgoing = 0; | 563 | keepgoing = 0; |
526 | 564 | ||
527 | /* Read status */ | 565 | /* Read status */ |
528 | status = in_be16(&PSC(port)->mpc52xx_psc_isr); | 566 | status = in_be16(&PSC(port)->mpc52xx_psc_isr); |
529 | status &= port->read_status_mask; | 567 | status &= port->read_status_mask; |
530 | 568 | ||
531 | /* Do we need to receive chars ? */ | 569 | /* Do we need to receive chars ? */ |
532 | /* For this RX interrupts must be on and some chars waiting */ | 570 | /* For this RX interrupts must be on and some chars waiting */ |
533 | if ( status & MPC52xx_PSC_IMR_RXRDY ) | 571 | if ( status & MPC52xx_PSC_IMR_RXRDY ) |
@@ -537,15 +575,15 @@ mpc52xx_uart_int(int irq, void *dev_id) | |||
537 | /* For this, TX must be ready and TX interrupt enabled */ | 575 | /* For this, TX must be ready and TX interrupt enabled */ |
538 | if ( status & MPC52xx_PSC_IMR_TXRDY ) | 576 | if ( status & MPC52xx_PSC_IMR_TXRDY ) |
539 | keepgoing |= mpc52xx_uart_int_tx_chars(port); | 577 | keepgoing |= mpc52xx_uart_int_tx_chars(port); |
540 | 578 | ||
541 | /* Limit number of iteration */ | 579 | /* Limit number of iteration */ |
542 | if ( !(--pass) ) | 580 | if ( !(--pass) ) |
543 | keepgoing = 0; | 581 | keepgoing = 0; |
544 | 582 | ||
545 | } while (keepgoing); | 583 | } while (keepgoing); |
546 | 584 | ||
547 | spin_unlock(&port->lock); | 585 | spin_unlock(&port->lock); |
548 | 586 | ||
549 | return IRQ_HANDLED; | 587 | return IRQ_HANDLED; |
550 | } | 588 | } |
551 | 589 | ||
@@ -563,13 +601,18 @@ mpc52xx_console_get_options(struct uart_port *port, | |||
563 | struct mpc52xx_psc __iomem *psc = PSC(port); | 601 | struct mpc52xx_psc __iomem *psc = PSC(port); |
564 | unsigned char mr1; | 602 | unsigned char mr1; |
565 | 603 | ||
604 | pr_debug("mpc52xx_console_get_options(port=%p)\n", port); | ||
605 | |||
566 | /* Read the mode registers */ | 606 | /* Read the mode registers */ |
567 | out_8(&psc->command,MPC52xx_PSC_SEL_MODE_REG_1); | 607 | out_8(&psc->command,MPC52xx_PSC_SEL_MODE_REG_1); |
568 | mr1 = in_8(&psc->mode); | 608 | mr1 = in_8(&psc->mode); |
569 | 609 | ||
570 | /* CT{U,L}R are write-only ! */ | 610 | /* CT{U,L}R are write-only ! */ |
571 | *baud = __res.bi_baudrate ? | 611 | *baud = CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD; |
572 | __res.bi_baudrate : CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD; | 612 | #if !defined(CONFIG_PPC_MERGE) |
613 | if (__res.bi_baudrate) | ||
614 | *baud = __res.bi_baudrate; | ||
615 | #endif | ||
573 | 616 | ||
574 | /* Parse them */ | 617 | /* Parse them */ |
575 | switch (mr1 & MPC52xx_PSC_MODE_BITS_MASK) { | 618 | switch (mr1 & MPC52xx_PSC_MODE_BITS_MASK) { |
@@ -579,26 +622,26 @@ mpc52xx_console_get_options(struct uart_port *port, | |||
579 | case MPC52xx_PSC_MODE_8_BITS: | 622 | case MPC52xx_PSC_MODE_8_BITS: |
580 | default: *bits = 8; | 623 | default: *bits = 8; |
581 | } | 624 | } |
582 | 625 | ||
583 | if (mr1 & MPC52xx_PSC_MODE_PARNONE) | 626 | if (mr1 & MPC52xx_PSC_MODE_PARNONE) |
584 | *parity = 'n'; | 627 | *parity = 'n'; |
585 | else | 628 | else |
586 | *parity = mr1 & MPC52xx_PSC_MODE_PARODD ? 'o' : 'e'; | 629 | *parity = mr1 & MPC52xx_PSC_MODE_PARODD ? 'o' : 'e'; |
587 | } | 630 | } |
588 | 631 | ||
589 | static void | 632 | static void |
590 | mpc52xx_console_write(struct console *co, const char *s, unsigned int count) | 633 | mpc52xx_console_write(struct console *co, const char *s, unsigned int count) |
591 | { | 634 | { |
592 | struct uart_port *port = &mpc52xx_uart_ports[co->index]; | 635 | struct uart_port *port = &mpc52xx_uart_ports[co->index]; |
593 | struct mpc52xx_psc __iomem *psc = PSC(port); | 636 | struct mpc52xx_psc __iomem *psc = PSC(port); |
594 | unsigned int i, j; | 637 | unsigned int i, j; |
595 | 638 | ||
596 | /* Disable interrupts */ | 639 | /* Disable interrupts */ |
597 | out_be16(&psc->mpc52xx_psc_imr, 0); | 640 | out_be16(&psc->mpc52xx_psc_imr, 0); |
598 | 641 | ||
599 | /* Wait the TX buffer to be empty */ | 642 | /* Wait the TX buffer to be empty */ |
600 | j = 5000000; /* Maximum wait */ | 643 | j = 5000000; /* Maximum wait */ |
601 | while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP) && | 644 | while (!(in_be16(&psc->mpc52xx_psc_status) & MPC52xx_PSC_SR_TXEMP) && |
602 | --j) | 645 | --j) |
603 | udelay(1); | 646 | udelay(1); |
604 | 647 | ||
@@ -607,13 +650,13 @@ mpc52xx_console_write(struct console *co, const char *s, unsigned int count) | |||
607 | /* Line return handling */ | 650 | /* Line return handling */ |
608 | if (*s == '\n') | 651 | if (*s == '\n') |
609 | out_8(&psc->mpc52xx_psc_buffer_8, '\r'); | 652 | out_8(&psc->mpc52xx_psc_buffer_8, '\r'); |
610 | 653 | ||
611 | /* Send the char */ | 654 | /* Send the char */ |
612 | out_8(&psc->mpc52xx_psc_buffer_8, *s); | 655 | out_8(&psc->mpc52xx_psc_buffer_8, *s); |
613 | 656 | ||
614 | /* Wait the TX buffer to be empty */ | 657 | /* Wait the TX buffer to be empty */ |
615 | j = 20000; /* Maximum wait */ | 658 | j = 20000; /* Maximum wait */ |
616 | while (!(in_be16(&psc->mpc52xx_psc_status) & | 659 | while (!(in_be16(&psc->mpc52xx_psc_status) & |
617 | MPC52xx_PSC_SR_TXEMP) && --j) | 660 | MPC52xx_PSC_SR_TXEMP) && --j) |
618 | udelay(1); | 661 | udelay(1); |
619 | } | 662 | } |
@@ -622,6 +665,7 @@ mpc52xx_console_write(struct console *co, const char *s, unsigned int count) | |||
622 | out_be16(&psc->mpc52xx_psc_imr, port->read_status_mask); | 665 | out_be16(&psc->mpc52xx_psc_imr, port->read_status_mask); |
623 | } | 666 | } |
624 | 667 | ||
668 | #if !defined(CONFIG_PPC_MERGE) | ||
625 | static int __init | 669 | static int __init |
626 | mpc52xx_console_setup(struct console *co, char *options) | 670 | mpc52xx_console_setup(struct console *co, char *options) |
627 | { | 671 | { |
@@ -634,7 +678,7 @@ mpc52xx_console_setup(struct console *co, char *options) | |||
634 | 678 | ||
635 | if (co->index < 0 || co->index >= MPC52xx_PSC_MAXNUM) | 679 | if (co->index < 0 || co->index >= MPC52xx_PSC_MAXNUM) |
636 | return -EINVAL; | 680 | return -EINVAL; |
637 | 681 | ||
638 | /* Basic port init. Needed since we use some uart_??? func before | 682 | /* Basic port init. Needed since we use some uart_??? func before |
639 | * real init for early access */ | 683 | * real init for early access */ |
640 | spin_lock_init(&port->lock); | 684 | spin_lock_init(&port->lock); |
@@ -656,6 +700,78 @@ mpc52xx_console_setup(struct console *co, char *options) | |||
656 | return uart_set_options(port, co, baud, parity, bits, flow); | 700 | return uart_set_options(port, co, baud, parity, bits, flow); |
657 | } | 701 | } |
658 | 702 | ||
703 | #else | ||
704 | |||
705 | static int __init | ||
706 | mpc52xx_console_setup(struct console *co, char *options) | ||
707 | { | ||
708 | struct uart_port *port = &mpc52xx_uart_ports[co->index]; | ||
709 | struct device_node *np = mpc52xx_uart_nodes[co->index]; | ||
710 | unsigned int ipb_freq; | ||
711 | struct resource res; | ||
712 | int ret; | ||
713 | |||
714 | int baud = CONFIG_SERIAL_MPC52xx_CONSOLE_BAUD; | ||
715 | int bits = 8; | ||
716 | int parity = 'n'; | ||
717 | int flow = 'n'; | ||
718 | |||
719 | pr_debug("mpc52xx_console_setup co=%p, co->index=%i, options=%s\n", | ||
720 | co, co->index, options); | ||
721 | |||
722 | if ((co->index < 0) || (co->index > MPC52xx_PSC_MAXNUM)) { | ||
723 | pr_debug("PSC%x out of range\n", co->index); | ||
724 | return -EINVAL; | ||
725 | } | ||
726 | |||
727 | if (!np) { | ||
728 | pr_debug("PSC%x not found in device tree\n", co->index); | ||
729 | return -EINVAL; | ||
730 | } | ||
731 | |||
732 | pr_debug("Console on ttyPSC%x is %s\n", | ||
733 | co->index, mpc52xx_uart_nodes[co->index]->full_name); | ||
734 | |||
735 | /* Fetch register locations */ | ||
736 | if ((ret = of_address_to_resource(np, 0, &res)) != 0) { | ||
737 | pr_debug("Could not get resources for PSC%x\n", co->index); | ||
738 | return ret; | ||
739 | } | ||
740 | |||
741 | /* Search for bus-frequency property in this node or a parent */ | ||
742 | if ((ipb_freq = mpc52xx_find_ipb_freq(np)) == 0) { | ||
743 | pr_debug("Could not find IPB bus frequency!\n"); | ||
744 | return -EINVAL; | ||
745 | } | ||
746 | |||
747 | /* Basic port init. Needed since we use some uart_??? func before | ||
748 | * real init for early access */ | ||
749 | spin_lock_init(&port->lock); | ||
750 | port->uartclk = ipb_freq / 2; | ||
751 | port->ops = &mpc52xx_uart_ops; | ||
752 | port->mapbase = res.start; | ||
753 | port->membase = ioremap(res.start, sizeof(struct mpc52xx_psc)); | ||
754 | port->irq = irq_of_parse_and_map(np, 0); | ||
755 | |||
756 | if (port->membase == NULL) | ||
757 | return -EINVAL; | ||
758 | |||
759 | pr_debug("mpc52xx-psc uart at %lx, mapped to %p, irq=%x, freq=%i\n", | ||
760 | port->mapbase, port->membase, port->irq, port->uartclk); | ||
761 | |||
762 | /* Setup the port parameters accoding to options */ | ||
763 | if (options) | ||
764 | uart_parse_options(options, &baud, &parity, &bits, &flow); | ||
765 | else | ||
766 | mpc52xx_console_get_options(port, &baud, &parity, &bits, &flow); | ||
767 | |||
768 | pr_debug("Setting console parameters: %i %i%c1 flow=%c\n", | ||
769 | baud, bits, parity, flow); | ||
770 | |||
771 | return uart_set_options(port, co, baud, parity, bits, flow); | ||
772 | } | ||
773 | #endif /* defined(CONFIG_PPC_MERGE) */ | ||
774 | |||
659 | 775 | ||
660 | static struct uart_driver mpc52xx_uart_driver; | 776 | static struct uart_driver mpc52xx_uart_driver; |
661 | 777 | ||
@@ -669,10 +785,11 @@ static struct console mpc52xx_console = { | |||
669 | .data = &mpc52xx_uart_driver, | 785 | .data = &mpc52xx_uart_driver, |
670 | }; | 786 | }; |
671 | 787 | ||
672 | 788 | ||
673 | static int __init | 789 | static int __init |
674 | mpc52xx_console_init(void) | 790 | mpc52xx_console_init(void) |
675 | { | 791 | { |
792 | mpc52xx_uart_of_enumerate(); | ||
676 | register_console(&mpc52xx_console); | 793 | register_console(&mpc52xx_console); |
677 | return 0; | 794 | return 0; |
678 | } | 795 | } |
@@ -700,6 +817,7 @@ static struct uart_driver mpc52xx_uart_driver = { | |||
700 | }; | 817 | }; |
701 | 818 | ||
702 | 819 | ||
820 | #if !defined(CONFIG_PPC_MERGE) | ||
703 | /* ======================================================================== */ | 821 | /* ======================================================================== */ |
704 | /* Platform Driver */ | 822 | /* Platform Driver */ |
705 | /* ======================================================================== */ | 823 | /* ======================================================================== */ |
@@ -723,8 +841,6 @@ mpc52xx_uart_probe(struct platform_device *dev) | |||
723 | /* Init the port structure */ | 841 | /* Init the port structure */ |
724 | port = &mpc52xx_uart_ports[idx]; | 842 | port = &mpc52xx_uart_ports[idx]; |
725 | 843 | ||
726 | memset(port, 0x00, sizeof(struct uart_port)); | ||
727 | |||
728 | spin_lock_init(&port->lock); | 844 | spin_lock_init(&port->lock); |
729 | port->uartclk = __res.bi_ipbfreq / 2; /* Look at CTLR doc */ | 845 | port->uartclk = __res.bi_ipbfreq / 2; /* Look at CTLR doc */ |
730 | port->fifosize = 512; | 846 | port->fifosize = 512; |
@@ -733,6 +849,7 @@ mpc52xx_uart_probe(struct platform_device *dev) | |||
733 | ( uart_console(port) ? 0 : UPF_IOREMAP ); | 849 | ( uart_console(port) ? 0 : UPF_IOREMAP ); |
734 | port->line = idx; | 850 | port->line = idx; |
735 | port->ops = &mpc52xx_uart_ops; | 851 | port->ops = &mpc52xx_uart_ops; |
852 | port->dev = &dev->dev; | ||
736 | 853 | ||
737 | /* Search for IRQ and mapbase */ | 854 | /* Search for IRQ and mapbase */ |
738 | for (i=0 ; i<dev->num_resources ; i++, res++) { | 855 | for (i=0 ; i<dev->num_resources ; i++, res++) { |
@@ -771,7 +888,7 @@ mpc52xx_uart_suspend(struct platform_device *dev, pm_message_t state) | |||
771 | { | 888 | { |
772 | struct uart_port *port = (struct uart_port *) platform_get_drvdata(dev); | 889 | struct uart_port *port = (struct uart_port *) platform_get_drvdata(dev); |
773 | 890 | ||
774 | if (sport) | 891 | if (port) |
775 | uart_suspend_port(&mpc52xx_uart_driver, port); | 892 | uart_suspend_port(&mpc52xx_uart_driver, port); |
776 | 893 | ||
777 | return 0; | 894 | return 0; |
@@ -789,6 +906,7 @@ mpc52xx_uart_resume(struct platform_device *dev) | |||
789 | } | 906 | } |
790 | #endif | 907 | #endif |
791 | 908 | ||
909 | |||
792 | static struct platform_driver mpc52xx_uart_platform_driver = { | 910 | static struct platform_driver mpc52xx_uart_platform_driver = { |
793 | .probe = mpc52xx_uart_probe, | 911 | .probe = mpc52xx_uart_probe, |
794 | .remove = mpc52xx_uart_remove, | 912 | .remove = mpc52xx_uart_remove, |
@@ -800,6 +918,184 @@ static struct platform_driver mpc52xx_uart_platform_driver = { | |||
800 | .name = "mpc52xx-psc", | 918 | .name = "mpc52xx-psc", |
801 | }, | 919 | }, |
802 | }; | 920 | }; |
921 | #endif /* !defined(CONFIG_PPC_MERGE) */ | ||
922 | |||
923 | |||
924 | #if defined(CONFIG_PPC_MERGE) | ||
925 | /* ======================================================================== */ | ||
926 | /* OF Platform Driver */ | ||
927 | /* ======================================================================== */ | ||
928 | |||
929 | static int __devinit | ||
930 | mpc52xx_uart_of_probe(struct of_device *op, const struct of_device_id *match) | ||
931 | { | ||
932 | int idx = -1; | ||
933 | unsigned int ipb_freq; | ||
934 | struct uart_port *port = NULL; | ||
935 | struct resource res; | ||
936 | int ret; | ||
937 | |||
938 | dev_dbg(&op->dev, "mpc52xx_uart_probe(op=%p, match=%p)\n", op, match); | ||
939 | |||
940 | /* Check validity & presence */ | ||
941 | for (idx = 0; idx < MPC52xx_PSC_MAXNUM; idx++) | ||
942 | if (mpc52xx_uart_nodes[idx] == op->node) | ||
943 | break; | ||
944 | if (idx >= MPC52xx_PSC_MAXNUM) | ||
945 | return -EINVAL; | ||
946 | pr_debug("Found %s assigned to ttyPSC%x\n", | ||
947 | mpc52xx_uart_nodes[idx]->full_name, idx); | ||
948 | |||
949 | /* Search for bus-frequency property in this node or a parent */ | ||
950 | if ((ipb_freq = mpc52xx_find_ipb_freq(op->node)) == 0) { | ||
951 | dev_dbg(&op->dev, "Could not find IPB bus frequency!\n"); | ||
952 | return -EINVAL; | ||
953 | } | ||
954 | |||
955 | /* Init the port structure */ | ||
956 | port = &mpc52xx_uart_ports[idx]; | ||
957 | |||
958 | spin_lock_init(&port->lock); | ||
959 | port->uartclk = ipb_freq / 2; | ||
960 | port->fifosize = 512; | ||
961 | port->iotype = UPIO_MEM; | ||
962 | port->flags = UPF_BOOT_AUTOCONF | | ||
963 | ( uart_console(port) ? 0 : UPF_IOREMAP ); | ||
964 | port->line = idx; | ||
965 | port->ops = &mpc52xx_uart_ops; | ||
966 | port->dev = &op->dev; | ||
967 | |||
968 | /* Search for IRQ and mapbase */ | ||
969 | if ((ret = of_address_to_resource(op->node, 0, &res)) != 0) | ||
970 | return ret; | ||
971 | |||
972 | port->mapbase = res.start; | ||
973 | port->irq = irq_of_parse_and_map(op->node, 0); | ||
974 | |||
975 | dev_dbg(&op->dev, "mpc52xx-psc uart at %lx, irq=%x, freq=%i\n", | ||
976 | port->mapbase, port->irq, port->uartclk); | ||
977 | |||
978 | if ((port->irq==NO_IRQ) || !port->mapbase) { | ||
979 | printk(KERN_ERR "Could not allocate resources for PSC\n"); | ||
980 | return -EINVAL; | ||
981 | } | ||
982 | |||
983 | /* Add the port to the uart sub-system */ | ||
984 | ret = uart_add_one_port(&mpc52xx_uart_driver, port); | ||
985 | if (!ret) | ||
986 | dev_set_drvdata(&op->dev, (void*)port); | ||
987 | |||
988 | return ret; | ||
989 | } | ||
990 | |||
991 | static int | ||
992 | mpc52xx_uart_of_remove(struct of_device *op) | ||
993 | { | ||
994 | struct uart_port *port = dev_get_drvdata(&op->dev); | ||
995 | dev_set_drvdata(&op->dev, NULL); | ||
996 | |||
997 | if (port) | ||
998 | uart_remove_one_port(&mpc52xx_uart_driver, port); | ||
999 | |||
1000 | return 0; | ||
1001 | } | ||
1002 | |||
1003 | #ifdef CONFIG_PM | ||
1004 | static int | ||
1005 | mpc52xx_uart_of_suspend(struct of_device *op, pm_message_t state) | ||
1006 | { | ||
1007 | struct uart_port *port = (struct uart_port *) dev_get_drvdata(&op->dev); | ||
1008 | |||
1009 | if (port) | ||
1010 | uart_suspend_port(&mpc52xx_uart_driver, port); | ||
1011 | |||
1012 | return 0; | ||
1013 | } | ||
1014 | |||
1015 | static int | ||
1016 | mpc52xx_uart_of_resume(struct of_device *op) | ||
1017 | { | ||
1018 | struct uart_port *port = (struct uart_port *) dev_get_drvdata(&op->dev); | ||
1019 | |||
1020 | if (port) | ||
1021 | uart_resume_port(&mpc52xx_uart_driver, port); | ||
1022 | |||
1023 | return 0; | ||
1024 | } | ||
1025 | #endif | ||
1026 | |||
1027 | static void | ||
1028 | mpc52xx_uart_of_assign(struct device_node *np, int idx) | ||
1029 | { | ||
1030 | int free_idx = -1; | ||
1031 | int i; | ||
1032 | |||
1033 | /* Find the first free node */ | ||
1034 | for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) { | ||
1035 | if (mpc52xx_uart_nodes[i] == NULL) { | ||
1036 | free_idx = i; | ||
1037 | break; | ||
1038 | } | ||
1039 | } | ||
1040 | |||
1041 | if ((idx < 0) || (idx >= MPC52xx_PSC_MAXNUM)) | ||
1042 | idx = free_idx; | ||
1043 | |||
1044 | if (idx < 0) | ||
1045 | return; /* No free slot; abort */ | ||
1046 | |||
1047 | /* If the slot is already occupied, then swap slots */ | ||
1048 | if (mpc52xx_uart_nodes[idx] && (free_idx != -1)) | ||
1049 | mpc52xx_uart_nodes[free_idx] = mpc52xx_uart_nodes[idx]; | ||
1050 | mpc52xx_uart_nodes[i] = np; | ||
1051 | } | ||
1052 | |||
1053 | static void | ||
1054 | mpc52xx_uart_of_enumerate(void) | ||
1055 | { | ||
1056 | static int enum_done = 0; | ||
1057 | struct device_node *np; | ||
1058 | const unsigned int *devno; | ||
1059 | int i; | ||
1060 | |||
1061 | if (enum_done) | ||
1062 | return; | ||
1063 | |||
1064 | for_each_node_by_type(np, "serial") { | ||
1065 | if (!of_match_node(mpc52xx_uart_of_match, np)) | ||
1066 | continue; | ||
1067 | |||
1068 | /* Is a particular device number requested? */ | ||
1069 | devno = get_property(np, "device_no", NULL); | ||
1070 | mpc52xx_uart_of_assign(of_node_get(np), devno ? *devno : -1); | ||
1071 | } | ||
1072 | |||
1073 | enum_done = 1; | ||
1074 | |||
1075 | for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) { | ||
1076 | if (mpc52xx_uart_nodes[i]) | ||
1077 | pr_debug("%s assigned to ttyPSC%x\n", | ||
1078 | mpc52xx_uart_nodes[i]->full_name, i); | ||
1079 | } | ||
1080 | } | ||
1081 | |||
1082 | MODULE_DEVICE_TABLE(of, mpc52xx_uart_of_match); | ||
1083 | |||
1084 | static struct of_platform_driver mpc52xx_uart_of_driver = { | ||
1085 | .owner = THIS_MODULE, | ||
1086 | .name = "mpc52xx-psc-uart", | ||
1087 | .match_table = mpc52xx_uart_of_match, | ||
1088 | .probe = mpc52xx_uart_of_probe, | ||
1089 | .remove = mpc52xx_uart_of_remove, | ||
1090 | #ifdef CONFIG_PM | ||
1091 | .suspend = mpc52xx_uart_of_suspend, | ||
1092 | .resume = mpc52xx_uart_of_resume, | ||
1093 | #endif | ||
1094 | .driver = { | ||
1095 | .name = "mpc52xx-psc-uart", | ||
1096 | }, | ||
1097 | }; | ||
1098 | #endif /* defined(CONFIG_PPC_MERGE) */ | ||
803 | 1099 | ||
804 | 1100 | ||
805 | /* ======================================================================== */ | 1101 | /* ======================================================================== */ |
@@ -811,22 +1107,45 @@ mpc52xx_uart_init(void) | |||
811 | { | 1107 | { |
812 | int ret; | 1108 | int ret; |
813 | 1109 | ||
814 | printk(KERN_INFO "Serial: MPC52xx PSC driver\n"); | 1110 | printk(KERN_INFO "Serial: MPC52xx PSC UART driver\n"); |
815 | 1111 | ||
816 | ret = uart_register_driver(&mpc52xx_uart_driver); | 1112 | if ((ret = uart_register_driver(&mpc52xx_uart_driver)) != 0) { |
817 | if (ret == 0) { | 1113 | printk(KERN_ERR "%s: uart_register_driver failed (%i)\n", |
818 | ret = platform_driver_register(&mpc52xx_uart_platform_driver); | 1114 | __FILE__, ret); |
819 | if (ret) | 1115 | return ret; |
820 | uart_unregister_driver(&mpc52xx_uart_driver); | ||
821 | } | 1116 | } |
822 | 1117 | ||
823 | return ret; | 1118 | #if defined(CONFIG_PPC_MERGE) |
1119 | mpc52xx_uart_of_enumerate(); | ||
1120 | |||
1121 | ret = of_register_platform_driver(&mpc52xx_uart_of_driver); | ||
1122 | if (ret) { | ||
1123 | printk(KERN_ERR "%s: of_register_platform_driver failed (%i)\n", | ||
1124 | __FILE__, ret); | ||
1125 | uart_unregister_driver(&mpc52xx_uart_driver); | ||
1126 | return ret; | ||
1127 | } | ||
1128 | #else | ||
1129 | ret = platform_driver_register(&mpc52xx_uart_platform_driver); | ||
1130 | if (ret) { | ||
1131 | printk(KERN_ERR "%s: platform_driver_register failed (%i)\n", | ||
1132 | __FILE__, ret); | ||
1133 | uart_unregister_driver(&mpc52xx_uart_driver); | ||
1134 | return ret; | ||
1135 | } | ||
1136 | #endif | ||
1137 | |||
1138 | return 0; | ||
824 | } | 1139 | } |
825 | 1140 | ||
826 | static void __exit | 1141 | static void __exit |
827 | mpc52xx_uart_exit(void) | 1142 | mpc52xx_uart_exit(void) |
828 | { | 1143 | { |
1144 | #if defined(CONFIG_PPC_MERGE) | ||
1145 | of_unregister_platform_driver(&mpc52xx_uart_of_driver); | ||
1146 | #else | ||
829 | platform_driver_unregister(&mpc52xx_uart_platform_driver); | 1147 | platform_driver_unregister(&mpc52xx_uart_platform_driver); |
1148 | #endif | ||
830 | uart_unregister_driver(&mpc52xx_uart_driver); | 1149 | uart_unregister_driver(&mpc52xx_uart_driver); |
831 | } | 1150 | } |
832 | 1151 | ||
diff --git a/drivers/video/platinumfb.c b/drivers/video/platinumfb.c index fdb33cd21a2..cb26c6df058 100644 --- a/drivers/video/platinumfb.c +++ b/drivers/video/platinumfb.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <asm/prom.h> | 34 | #include <asm/prom.h> |
35 | #include <asm/pgtable.h> | 35 | #include <asm/pgtable.h> |
36 | #include <asm/of_device.h> | 36 | #include <asm/of_device.h> |
37 | #include <asm/of_platform.h> | ||
37 | 38 | ||
38 | #include "macmodes.h" | 39 | #include "macmodes.h" |
39 | #include "platinumfb.h" | 40 | #include "platinumfb.h" |
@@ -682,14 +683,14 @@ static int __init platinumfb_init(void) | |||
682 | return -ENODEV; | 683 | return -ENODEV; |
683 | platinumfb_setup(option); | 684 | platinumfb_setup(option); |
684 | #endif | 685 | #endif |
685 | of_register_driver(&platinum_driver); | 686 | of_register_platform_driver(&platinum_driver); |
686 | 687 | ||
687 | return 0; | 688 | return 0; |
688 | } | 689 | } |
689 | 690 | ||
690 | static void __exit platinumfb_exit(void) | 691 | static void __exit platinumfb_exit(void) |
691 | { | 692 | { |
692 | of_unregister_driver(&platinum_driver); | 693 | of_unregister_platform_driver(&platinum_driver); |
693 | } | 694 | } |
694 | 695 | ||
695 | MODULE_LICENSE("GPL"); | 696 | MODULE_LICENSE("GPL"); |