0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <linux/module.h>
0013 #include <linux/init.h>
0014 #include <linux/kernel.h>
0015 #include <linux/platform_data/sa11x0-serial.h>
0016 #include <linux/platform_device.h>
0017 #include <linux/delay.h>
0018 #include <linux/tty.h>
0019 #include <linux/mtd/mtd.h>
0020 #include <linux/mtd/partitions.h>
0021 #include <linux/errno.h>
0022 #include <linux/gpio.h>
0023 #include <linux/leds.h>
0024
0025 #include <mach/hardware.h>
0026 #include <asm/mach-types.h>
0027 #include <asm/setup.h>
0028 #include <mach/irqs.h>
0029
0030 #include <asm/mach/arch.h>
0031 #include <asm/mach/flash.h>
0032 #include <asm/mach/map.h>
0033 #include <asm/hardware/sa1111.h>
0034
0035 #include <mach/badge4.h>
0036
0037 #include "generic.h"
0038
0039 static struct resource sa1111_resources[] = {
0040 [0] = DEFINE_RES_MEM(BADGE4_SA1111_BASE, 0x2000),
0041 [1] = DEFINE_RES_IRQ(BADGE4_IRQ_GPIO_SA1111),
0042 };
0043
0044 static int badge4_sa1111_enable(void *data, unsigned devid)
0045 {
0046 if (devid == SA1111_DEVID_USB)
0047 badge4_set_5V(BADGE4_5V_USB, 1);
0048 return 0;
0049 }
0050
0051 static void badge4_sa1111_disable(void *data, unsigned devid)
0052 {
0053 if (devid == SA1111_DEVID_USB)
0054 badge4_set_5V(BADGE4_5V_USB, 0);
0055 }
0056
0057 static struct sa1111_platform_data sa1111_info = {
0058 .disable_devs = SA1111_DEVID_PS2_MSE,
0059 .enable = badge4_sa1111_enable,
0060 .disable = badge4_sa1111_disable,
0061 };
0062
0063 static u64 sa1111_dmamask = 0xffffffffUL;
0064
0065 static struct platform_device sa1111_device = {
0066 .name = "sa1111",
0067 .id = 0,
0068 .dev = {
0069 .dma_mask = &sa1111_dmamask,
0070 .coherent_dma_mask = 0xffffffff,
0071 .platform_data = &sa1111_info,
0072 },
0073 .num_resources = ARRAY_SIZE(sa1111_resources),
0074 .resource = sa1111_resources,
0075 };
0076
0077
0078 struct gpio_led badge4_gpio_leds[] = {
0079 {
0080 .name = "badge4:red",
0081 .default_trigger = "heartbeat",
0082 .gpio = 7,
0083 },
0084 {
0085 .name = "badge4:green",
0086 .default_trigger = "cpu0",
0087 .gpio = 9,
0088 },
0089 };
0090
0091 static struct gpio_led_platform_data badge4_gpio_led_info = {
0092 .leds = badge4_gpio_leds,
0093 .num_leds = ARRAY_SIZE(badge4_gpio_leds),
0094 };
0095
0096 static struct platform_device badge4_leds = {
0097 .name = "leds-gpio",
0098 .id = -1,
0099 .dev = {
0100 .platform_data = &badge4_gpio_led_info,
0101 }
0102 };
0103
0104 static struct platform_device *devices[] __initdata = {
0105 &sa1111_device,
0106 &badge4_leds,
0107 };
0108
0109 static int __init badge4_sa1111_init(void)
0110 {
0111
0112
0113
0114
0115 sa1110_mb_disable();
0116
0117
0118
0119
0120 return platform_add_devices(devices, ARRAY_SIZE(devices));
0121 }
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135 static struct mtd_partition badge4_partitions[] = {
0136 {
0137 .name = "BLOB boot loader",
0138 .offset = 0,
0139 .size = 0x0000A000
0140 }, {
0141 .name = "params",
0142 .offset = MTDPART_OFS_APPEND,
0143 .size = 0x00006000
0144 }, {
0145 .name = "root",
0146 .offset = MTDPART_OFS_APPEND,
0147 .size = MTDPART_SIZ_FULL
0148 }
0149 };
0150
0151 static struct flash_platform_data badge4_flash_data = {
0152 .map_name = "cfi_probe",
0153 .parts = badge4_partitions,
0154 .nr_parts = ARRAY_SIZE(badge4_partitions),
0155 };
0156
0157 static struct resource badge4_flash_resource =
0158 DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_64M);
0159
0160 static int five_v_on __initdata = 0;
0161
0162 static int __init five_v_on_setup(char *ignore)
0163 {
0164 five_v_on = 1;
0165 return 1;
0166 }
0167 __setup("five_v_on", five_v_on_setup);
0168
0169
0170 static int __init badge4_init(void)
0171 {
0172 int ret;
0173
0174 if (!machine_is_badge4())
0175 return -ENODEV;
0176
0177
0178 GPCR = (BADGE4_GPIO_LGP2 | BADGE4_GPIO_LGP3 |
0179 BADGE4_GPIO_LGP4 | BADGE4_GPIO_LGP5 |
0180 BADGE4_GPIO_LGP6 | BADGE4_GPIO_LGP7 |
0181 BADGE4_GPIO_LGP8 | BADGE4_GPIO_LGP9 |
0182 BADGE4_GPIO_GPA_VID | BADGE4_GPIO_GPB_VID |
0183 BADGE4_GPIO_GPC_VID);
0184 GPDR &= ~BADGE4_GPIO_INT_VID;
0185 GPDR |= (BADGE4_GPIO_LGP2 | BADGE4_GPIO_LGP3 |
0186 BADGE4_GPIO_LGP4 | BADGE4_GPIO_LGP5 |
0187 BADGE4_GPIO_LGP6 | BADGE4_GPIO_LGP7 |
0188 BADGE4_GPIO_LGP8 | BADGE4_GPIO_LGP9 |
0189 BADGE4_GPIO_GPA_VID | BADGE4_GPIO_GPB_VID |
0190 BADGE4_GPIO_GPC_VID);
0191
0192
0193 GPCR = (BADGE4_GPIO_SDSDA | BADGE4_GPIO_SDSCL);
0194 GPDR |= (BADGE4_GPIO_SDSDA | BADGE4_GPIO_SDSCL);
0195
0196
0197 GPCR = (BADGE4_GPIO_UART_HS1 | BADGE4_GPIO_UART_HS2);
0198 GPDR |= (BADGE4_GPIO_UART_HS1 | BADGE4_GPIO_UART_HS2);
0199
0200
0201 GPCR = BADGE4_GPIO_MUXSEL0;
0202 GPDR |= BADGE4_GPIO_MUXSEL0;
0203
0204
0205 GPDR &= ~(BADGE4_GPIO_TESTPT_J5 | BADGE4_GPIO_TESTPT_J6);
0206 GPCR = BADGE4_GPIO_TESTPT_J7;
0207 GPDR |= BADGE4_GPIO_TESTPT_J7;
0208
0209
0210 GPCR = BADGE4_GPIO_PCMEN5V;
0211 GPDR |= BADGE4_GPIO_PCMEN5V;
0212
0213
0214
0215 printk(KERN_DEBUG __FILE__ ": SDRAM CPLD typ1=%d typ0=%d\n",
0216 !!(GPLR & BADGE4_GPIO_SDTYP1),
0217 !!(GPLR & BADGE4_GPIO_SDTYP0));
0218
0219
0220
0221
0222
0223
0224
0225 PGSR = 0;
0226 PWER = 0;
0227 PCFR = 0;
0228 PSDR = 0;
0229
0230 PWER |= PWER_GPIO26;
0231 PWER |= PWER_RTC;
0232
0233
0234 PGSR |= BADGE4_GPIO_SA1111_NRST;
0235
0236 PGSR |= (GPLR & (BADGE4_GPIO_SDTYP0|BADGE4_GPIO_SDTYP1));
0237
0238
0239
0240 ret = badge4_sa1111_init();
0241 if (ret < 0)
0242 printk(KERN_ERR
0243 "%s: SA-1111 initialization failed (%d)\n",
0244 __func__, ret);
0245
0246
0247
0248 badge4_set_5V(BADGE4_5V_INITIALLY, five_v_on);
0249
0250 sa11x0_register_mtd(&badge4_flash_data, &badge4_flash_resource, 1);
0251
0252 return 0;
0253 }
0254
0255 arch_initcall(badge4_init);
0256
0257
0258 static unsigned badge4_5V_bitmap = 0;
0259
0260 void badge4_set_5V(unsigned subsystem, int on)
0261 {
0262 unsigned long flags;
0263 unsigned old_5V_bitmap;
0264
0265 local_irq_save(flags);
0266
0267 old_5V_bitmap = badge4_5V_bitmap;
0268
0269 if (on) {
0270 badge4_5V_bitmap |= subsystem;
0271 } else {
0272 badge4_5V_bitmap &= ~subsystem;
0273 }
0274
0275
0276 if ((!old_5V_bitmap) && (badge4_5V_bitmap)) {
0277
0278 printk(KERN_INFO "%s: enabling 5V supply rail\n", __func__);
0279 GPSR = BADGE4_GPIO_PCMEN5V;
0280 } else if ((old_5V_bitmap) && (!badge4_5V_bitmap)) {
0281
0282 printk(KERN_INFO "%s: disabling 5V supply rail\n", __func__);
0283 GPCR = BADGE4_GPIO_PCMEN5V;
0284 }
0285
0286 local_irq_restore(flags);
0287 }
0288 EXPORT_SYMBOL(badge4_set_5V);
0289
0290
0291 static struct map_desc badge4_io_desc[] __initdata = {
0292 {
0293 .virtual = 0xf1000000,
0294 .pfn = __phys_to_pfn(0x08000000),
0295 .length = 0x00100000,
0296 .type = MT_DEVICE
0297 }, {
0298 .virtual = 0xf2000000,
0299 .pfn = __phys_to_pfn(0x10000000),
0300 .length = 0x00100000,
0301 .type = MT_DEVICE
0302 }
0303 };
0304
0305 static void
0306 badge4_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
0307 {
0308 if (!state) {
0309 Ser1SDCR0 |= SDCR0_UART;
0310 }
0311 }
0312
0313 static struct sa1100_port_fns badge4_port_fns __initdata = {
0314 .pm = badge4_uart_pm,
0315 };
0316
0317 static void __init badge4_map_io(void)
0318 {
0319 sa1100_map_io();
0320 iotable_init(badge4_io_desc, ARRAY_SIZE(badge4_io_desc));
0321
0322 sa1100_register_uart_fns(&badge4_port_fns);
0323 sa1100_register_uart(0, 3);
0324 sa1100_register_uart(1, 1);
0325 }
0326
0327 MACHINE_START(BADGE4, "Hewlett-Packard Laboratories BadgePAD 4")
0328 .atag_offset = 0x100,
0329 .map_io = badge4_map_io,
0330 .nr_irqs = SA1100_NR_IRQS,
0331 .init_irq = sa1100_init_irq,
0332 .init_late = sa11x0_init_late,
0333 .init_time = sa1100_timer_init,
0334 #ifdef CONFIG_SA1111
0335 .dma_zone_size = SZ_1M,
0336 #endif
0337 .restart = sa11x0_restart,
0338 MACHINE_END