2 * arch/arm/mach-spear3xx/spear300.c
4 * SPEAr300 machine source file
6 * Copyright (C) 2009 ST Microelectronics
7 * Viresh Kumar<viresh.kumar@st.com>
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
14 #include <linux/types.h>
15 #include <linux/amba/pl061.h>
16 #include <linux/ptrace.h>
18 #include <plat/shirq.h>
19 #include <mach/generic.h>
20 #include <mach/hardware.h>
22 /* pad multiplexing support */
23 /* muxing registers */
24 #define PAD_MUX_CONFIG_REG 0x00
25 #define MODE_CONFIG_REG 0x04
28 #define NAND_MODE (1 << 0)
29 #define NOR_MODE (1 << 1)
30 #define PHOTO_FRAME_MODE (1 << 2)
31 #define LEND_IP_PHONE_MODE (1 << 3)
32 #define HEND_IP_PHONE_MODE (1 << 4)
33 #define LEND_WIFI_PHONE_MODE (1 << 5)
34 #define HEND_WIFI_PHONE_MODE (1 << 6)
35 #define ATA_PABX_WI2S_MODE (1 << 7)
36 #define ATA_PABX_I2S_MODE (1 << 8)
37 #define CAML_LCDW_MODE (1 << 9)
38 #define CAMU_LCD_MODE (1 << 10)
39 #define CAMU_WLCD_MODE (1 << 11)
40 #define CAML_LCD_MODE (1 << 12)
41 #define ALL_MODES 0x1FFF
43 struct pmx_mode spear300_nand_mode
= {
49 struct pmx_mode spear300_nor_mode
= {
55 struct pmx_mode spear300_photo_frame_mode
= {
56 .id
= PHOTO_FRAME_MODE
,
57 .name
= "photo frame mode",
61 struct pmx_mode spear300_lend_ip_phone_mode
= {
62 .id
= LEND_IP_PHONE_MODE
,
63 .name
= "lend ip phone mode",
67 struct pmx_mode spear300_hend_ip_phone_mode
= {
68 .id
= HEND_IP_PHONE_MODE
,
69 .name
= "hend ip phone mode",
73 struct pmx_mode spear300_lend_wifi_phone_mode
= {
74 .id
= LEND_WIFI_PHONE_MODE
,
75 .name
= "lend wifi phone mode",
79 struct pmx_mode spear300_hend_wifi_phone_mode
= {
80 .id
= HEND_WIFI_PHONE_MODE
,
81 .name
= "hend wifi phone mode",
85 struct pmx_mode spear300_ata_pabx_wi2s_mode
= {
86 .id
= ATA_PABX_WI2S_MODE
,
87 .name
= "ata pabx wi2s mode",
91 struct pmx_mode spear300_ata_pabx_i2s_mode
= {
92 .id
= ATA_PABX_I2S_MODE
,
93 .name
= "ata pabx i2s mode",
97 struct pmx_mode spear300_caml_lcdw_mode
= {
99 .name
= "caml lcdw mode",
103 struct pmx_mode spear300_camu_lcd_mode
= {
105 .name
= "camu lcd mode",
109 struct pmx_mode spear300_camu_wlcd_mode
= {
110 .id
= CAMU_WLCD_MODE
,
111 .name
= "camu wlcd mode",
115 struct pmx_mode spear300_caml_lcd_mode
= {
117 .name
= "caml lcd mode",
122 static struct pmx_dev_mode pmx_fsmc_2_chips_modes
[] = {
124 .ids
= NAND_MODE
| NOR_MODE
| PHOTO_FRAME_MODE
|
125 ATA_PABX_WI2S_MODE
| ATA_PABX_I2S_MODE
,
126 .mask
= PMX_FIRDA_MASK
,
130 struct pmx_dev spear300_pmx_fsmc_2_chips
= {
131 .name
= "fsmc_2_chips",
132 .modes
= pmx_fsmc_2_chips_modes
,
133 .mode_count
= ARRAY_SIZE(pmx_fsmc_2_chips_modes
),
137 static struct pmx_dev_mode pmx_fsmc_4_chips_modes
[] = {
139 .ids
= NAND_MODE
| NOR_MODE
| PHOTO_FRAME_MODE
|
140 ATA_PABX_WI2S_MODE
| ATA_PABX_I2S_MODE
,
141 .mask
= PMX_FIRDA_MASK
| PMX_UART0_MASK
,
145 struct pmx_dev spear300_pmx_fsmc_4_chips
= {
146 .name
= "fsmc_4_chips",
147 .modes
= pmx_fsmc_4_chips_modes
,
148 .mode_count
= ARRAY_SIZE(pmx_fsmc_4_chips_modes
),
152 static struct pmx_dev_mode pmx_keyboard_modes
[] = {
154 .ids
= LEND_IP_PHONE_MODE
| HEND_IP_PHONE_MODE
|
155 LEND_WIFI_PHONE_MODE
| HEND_WIFI_PHONE_MODE
|
156 CAML_LCDW_MODE
| CAMU_LCD_MODE
| CAMU_WLCD_MODE
|
162 struct pmx_dev spear300_pmx_keyboard
= {
164 .modes
= pmx_keyboard_modes
,
165 .mode_count
= ARRAY_SIZE(pmx_keyboard_modes
),
169 static struct pmx_dev_mode pmx_clcd_modes
[] = {
171 .ids
= PHOTO_FRAME_MODE
,
172 .mask
= PMX_TIMER_1_2_MASK
| PMX_TIMER_3_4_MASK
,
174 .ids
= HEND_IP_PHONE_MODE
| HEND_WIFI_PHONE_MODE
|
175 CAMU_LCD_MODE
| CAML_LCD_MODE
,
176 .mask
= PMX_TIMER_3_4_MASK
,
180 struct pmx_dev spear300_pmx_clcd
= {
182 .modes
= pmx_clcd_modes
,
183 .mode_count
= ARRAY_SIZE(pmx_clcd_modes
),
187 static struct pmx_dev_mode pmx_telecom_gpio_modes
[] = {
189 .ids
= PHOTO_FRAME_MODE
| CAMU_LCD_MODE
| CAML_LCD_MODE
,
190 .mask
= PMX_MII_MASK
,
192 .ids
= LEND_IP_PHONE_MODE
| LEND_WIFI_PHONE_MODE
,
193 .mask
= PMX_MII_MASK
| PMX_TIMER_1_2_MASK
| PMX_TIMER_3_4_MASK
,
195 .ids
= ATA_PABX_I2S_MODE
| CAML_LCDW_MODE
| CAMU_WLCD_MODE
,
196 .mask
= PMX_MII_MASK
| PMX_TIMER_3_4_MASK
,
198 .ids
= HEND_IP_PHONE_MODE
| HEND_WIFI_PHONE_MODE
,
199 .mask
= PMX_MII_MASK
| PMX_TIMER_1_2_MASK
,
201 .ids
= ATA_PABX_WI2S_MODE
,
202 .mask
= PMX_MII_MASK
| PMX_TIMER_1_2_MASK
| PMX_TIMER_3_4_MASK
203 | PMX_UART0_MODEM_MASK
,
207 struct pmx_dev spear300_pmx_telecom_gpio
= {
208 .name
= "telecom_gpio",
209 .modes
= pmx_telecom_gpio_modes
,
210 .mode_count
= ARRAY_SIZE(pmx_telecom_gpio_modes
),
214 static struct pmx_dev_mode pmx_telecom_tdm_modes
[] = {
216 .ids
= PHOTO_FRAME_MODE
| LEND_IP_PHONE_MODE
|
217 HEND_IP_PHONE_MODE
| LEND_WIFI_PHONE_MODE
218 | HEND_WIFI_PHONE_MODE
| ATA_PABX_WI2S_MODE
219 | ATA_PABX_I2S_MODE
| CAML_LCDW_MODE
| CAMU_LCD_MODE
220 | CAMU_WLCD_MODE
| CAML_LCD_MODE
,
221 .mask
= PMX_UART0_MODEM_MASK
| PMX_SSP_CS_MASK
,
225 struct pmx_dev spear300_pmx_telecom_tdm
= {
226 .name
= "telecom_tdm",
227 .modes
= pmx_telecom_tdm_modes
,
228 .mode_count
= ARRAY_SIZE(pmx_telecom_tdm_modes
),
232 static struct pmx_dev_mode pmx_telecom_spi_cs_i2c_clk_modes
[] = {
234 .ids
= LEND_IP_PHONE_MODE
| HEND_IP_PHONE_MODE
|
235 LEND_WIFI_PHONE_MODE
| HEND_WIFI_PHONE_MODE
236 | ATA_PABX_WI2S_MODE
| ATA_PABX_I2S_MODE
|
237 CAML_LCDW_MODE
| CAML_LCD_MODE
,
238 .mask
= PMX_TIMER_1_2_MASK
| PMX_TIMER_3_4_MASK
,
242 struct pmx_dev spear300_pmx_telecom_spi_cs_i2c_clk
= {
243 .name
= "telecom_spi_cs_i2c_clk",
244 .modes
= pmx_telecom_spi_cs_i2c_clk_modes
,
245 .mode_count
= ARRAY_SIZE(pmx_telecom_spi_cs_i2c_clk_modes
),
249 static struct pmx_dev_mode pmx_telecom_camera_modes
[] = {
251 .ids
= CAML_LCDW_MODE
| CAML_LCD_MODE
,
252 .mask
= PMX_MII_MASK
,
254 .ids
= CAMU_LCD_MODE
| CAMU_WLCD_MODE
,
255 .mask
= PMX_TIMER_1_2_MASK
| PMX_TIMER_3_4_MASK
| PMX_MII_MASK
,
259 struct pmx_dev spear300_pmx_telecom_camera
= {
260 .name
= "telecom_camera",
261 .modes
= pmx_telecom_camera_modes
,
262 .mode_count
= ARRAY_SIZE(pmx_telecom_camera_modes
),
266 static struct pmx_dev_mode pmx_telecom_dac_modes
[] = {
268 .ids
= ATA_PABX_I2S_MODE
| CAML_LCDW_MODE
| CAMU_LCD_MODE
269 | CAMU_WLCD_MODE
| CAML_LCD_MODE
,
270 .mask
= PMX_TIMER_1_2_MASK
,
274 struct pmx_dev spear300_pmx_telecom_dac
= {
275 .name
= "telecom_dac",
276 .modes
= pmx_telecom_dac_modes
,
277 .mode_count
= ARRAY_SIZE(pmx_telecom_dac_modes
),
281 static struct pmx_dev_mode pmx_telecom_i2s_modes
[] = {
283 .ids
= LEND_IP_PHONE_MODE
| HEND_IP_PHONE_MODE
284 | LEND_WIFI_PHONE_MODE
| HEND_WIFI_PHONE_MODE
|
285 ATA_PABX_I2S_MODE
| CAML_LCDW_MODE
| CAMU_LCD_MODE
286 | CAMU_WLCD_MODE
| CAML_LCD_MODE
,
287 .mask
= PMX_UART0_MODEM_MASK
,
291 struct pmx_dev spear300_pmx_telecom_i2s
= {
292 .name
= "telecom_i2s",
293 .modes
= pmx_telecom_i2s_modes
,
294 .mode_count
= ARRAY_SIZE(pmx_telecom_i2s_modes
),
298 static struct pmx_dev_mode pmx_telecom_boot_pins_modes
[] = {
300 .ids
= NAND_MODE
| NOR_MODE
,
301 .mask
= PMX_UART0_MODEM_MASK
| PMX_TIMER_1_2_MASK
|
306 struct pmx_dev spear300_pmx_telecom_boot_pins
= {
307 .name
= "telecom_boot_pins",
308 .modes
= pmx_telecom_boot_pins_modes
,
309 .mode_count
= ARRAY_SIZE(pmx_telecom_boot_pins_modes
),
313 static struct pmx_dev_mode pmx_telecom_sdhci_4bit_modes
[] = {
315 .ids
= PHOTO_FRAME_MODE
| LEND_IP_PHONE_MODE
|
316 HEND_IP_PHONE_MODE
| LEND_WIFI_PHONE_MODE
|
317 HEND_WIFI_PHONE_MODE
| CAML_LCDW_MODE
| CAMU_LCD_MODE
|
318 CAMU_WLCD_MODE
| CAML_LCD_MODE
| ATA_PABX_WI2S_MODE
|
320 .mask
= PMX_GPIO_PIN0_MASK
| PMX_GPIO_PIN1_MASK
|
321 PMX_GPIO_PIN2_MASK
| PMX_GPIO_PIN3_MASK
|
322 PMX_GPIO_PIN4_MASK
| PMX_GPIO_PIN5_MASK
,
326 struct pmx_dev spear300_pmx_telecom_sdhci_4bit
= {
327 .name
= "telecom_sdhci_4bit",
328 .modes
= pmx_telecom_sdhci_4bit_modes
,
329 .mode_count
= ARRAY_SIZE(pmx_telecom_sdhci_4bit_modes
),
333 static struct pmx_dev_mode pmx_telecom_sdhci_8bit_modes
[] = {
335 .ids
= PHOTO_FRAME_MODE
| LEND_IP_PHONE_MODE
|
336 HEND_IP_PHONE_MODE
| LEND_WIFI_PHONE_MODE
|
337 HEND_WIFI_PHONE_MODE
| CAML_LCDW_MODE
| CAMU_LCD_MODE
|
338 CAMU_WLCD_MODE
| CAML_LCD_MODE
,
339 .mask
= PMX_GPIO_PIN0_MASK
| PMX_GPIO_PIN1_MASK
|
340 PMX_GPIO_PIN2_MASK
| PMX_GPIO_PIN3_MASK
|
341 PMX_GPIO_PIN4_MASK
| PMX_GPIO_PIN5_MASK
| PMX_MII_MASK
,
345 struct pmx_dev spear300_pmx_telecom_sdhci_8bit
= {
346 .name
= "telecom_sdhci_8bit",
347 .modes
= pmx_telecom_sdhci_8bit_modes
,
348 .mode_count
= ARRAY_SIZE(pmx_telecom_sdhci_8bit_modes
),
352 static struct pmx_dev_mode pmx_gpio1_modes
[] = {
354 .ids
= PHOTO_FRAME_MODE
,
355 .mask
= PMX_UART0_MODEM_MASK
| PMX_TIMER_1_2_MASK
|
360 struct pmx_dev spear300_pmx_gpio1
= {
362 .modes
= pmx_gpio1_modes
,
363 .mode_count
= ARRAY_SIZE(pmx_gpio1_modes
),
367 /* pmx driver structure */
368 static struct pmx_driver pmx_driver
= {
369 .mode_reg
= {.offset
= MODE_CONFIG_REG
, .mask
= 0x0000000f},
370 .mux_reg
= {.offset
= PAD_MUX_CONFIG_REG
, .mask
= 0x00007fff},
373 /* spear3xx shared irq */
374 static struct shirq_dev_config shirq_ras1_config
[] = {
376 .virq
= SPEAR300_VIRQ_IT_PERS_S
,
377 .enb_mask
= SPEAR300_IT_PERS_S_IRQ_MASK
,
378 .status_mask
= SPEAR300_IT_PERS_S_IRQ_MASK
,
380 .virq
= SPEAR300_VIRQ_IT_CHANGE_S
,
381 .enb_mask
= SPEAR300_IT_CHANGE_S_IRQ_MASK
,
382 .status_mask
= SPEAR300_IT_CHANGE_S_IRQ_MASK
,
384 .virq
= SPEAR300_VIRQ_I2S
,
385 .enb_mask
= SPEAR300_I2S_IRQ_MASK
,
386 .status_mask
= SPEAR300_I2S_IRQ_MASK
,
388 .virq
= SPEAR300_VIRQ_TDM
,
389 .enb_mask
= SPEAR300_TDM_IRQ_MASK
,
390 .status_mask
= SPEAR300_TDM_IRQ_MASK
,
392 .virq
= SPEAR300_VIRQ_CAMERA_L
,
393 .enb_mask
= SPEAR300_CAMERA_L_IRQ_MASK
,
394 .status_mask
= SPEAR300_CAMERA_L_IRQ_MASK
,
396 .virq
= SPEAR300_VIRQ_CAMERA_F
,
397 .enb_mask
= SPEAR300_CAMERA_F_IRQ_MASK
,
398 .status_mask
= SPEAR300_CAMERA_F_IRQ_MASK
,
400 .virq
= SPEAR300_VIRQ_CAMERA_V
,
401 .enb_mask
= SPEAR300_CAMERA_V_IRQ_MASK
,
402 .status_mask
= SPEAR300_CAMERA_V_IRQ_MASK
,
404 .virq
= SPEAR300_VIRQ_KEYBOARD
,
405 .enb_mask
= SPEAR300_KEYBOARD_IRQ_MASK
,
406 .status_mask
= SPEAR300_KEYBOARD_IRQ_MASK
,
408 .virq
= SPEAR300_VIRQ_GPIO1
,
409 .enb_mask
= SPEAR300_GPIO1_IRQ_MASK
,
410 .status_mask
= SPEAR300_GPIO1_IRQ_MASK
,
414 static struct spear_shirq shirq_ras1
= {
415 .irq
= SPEAR3XX_IRQ_GEN_RAS_1
,
416 .dev_config
= shirq_ras1_config
,
417 .dev_count
= ARRAY_SIZE(shirq_ras1_config
),
419 .enb_reg
= SPEAR300_INT_ENB_MASK_REG
,
420 .status_reg
= SPEAR300_INT_STS_MASK_REG
,
421 .status_reg_mask
= SPEAR300_SHIRQ_RAS1_MASK
,
426 /* Add spear300 specific devices here */
427 /* arm gpio1 device registration */
428 static struct pl061_platform_data gpio1_plat_data
= {
430 .irq_base
= SPEAR300_GPIO1_INT_BASE
,
433 struct amba_device gpio1_device
= {
435 .init_name
= "gpio1",
436 .platform_data
= &gpio1_plat_data
,
439 .start
= SPEAR300_GPIO_BASE
,
440 .end
= SPEAR300_GPIO_BASE
+ SZ_4K
- 1,
441 .flags
= IORESOURCE_MEM
,
443 .irq
= {SPEAR300_VIRQ_GPIO1
, NO_IRQ
},
446 /* spear300 routines */
447 void __init
spear300_init(struct pmx_mode
*pmx_mode
, struct pmx_dev
**pmx_devs
,
452 /* call spear3xx family common init function */
455 /* shared irq registration */
456 shirq_ras1
.regs
.base
= ioremap(SPEAR300_TELECOM_BASE
, SZ_4K
);
457 if (shirq_ras1
.regs
.base
) {
458 ret
= spear_shirq_register(&shirq_ras1
);
460 printk(KERN_ERR
"Error registering Shared IRQ\n");
463 /* pmx initialization */
464 pmx_driver
.mode
= pmx_mode
;
465 pmx_driver
.devs
= pmx_devs
;
466 pmx_driver
.devs_count
= pmx_dev_count
;
468 pmx_driver
.base
= ioremap(SPEAR300_SOC_CONFIG_BASE
, SZ_4K
);
469 if (pmx_driver
.base
) {
470 ret
= pmx_register(&pmx_driver
);
472 printk(KERN_ERR
"padmux: registeration failed. err no"
474 /* Free Mapping, device selection already done */
475 iounmap(pmx_driver
.base
);