0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <linux/module.h>
0016 #include <linux/kernel.h>
0017 #include <linux/init.h>
0018 #include <linux/platform_device.h>
0019 #include <linux/interrupt.h>
0020 #include <linux/delay.h>
0021 #include <linux/mtd/mtd.h>
0022 #include <linux/mtd/partitions.h>
0023 #include <linux/gpio/machine.h>
0024 #include <linux/gpio.h>
0025 #include <linux/err.h>
0026 #include <linux/clk.h>
0027
0028 #include <asm/setup.h>
0029 #include <asm/memory.h>
0030 #include <asm/mach-types.h>
0031 #include <asm/irq.h>
0032 #include <linux/sizes.h>
0033
0034 #include <asm/mach/arch.h>
0035 #include <asm/mach/map.h>
0036 #include <asm/mach/irq.h>
0037 #include <asm/mach/flash.h>
0038
0039 #include "pxa25x.h"
0040 #include <linux/platform_data/mmc-pxamci.h>
0041 #include "udc.h"
0042 #include "gumstix.h"
0043
0044 #include "generic.h"
0045
0046 static struct resource flash_resource = {
0047 .start = 0x00000000,
0048 .end = SZ_64M - 1,
0049 .flags = IORESOURCE_MEM,
0050 };
0051
0052 static struct mtd_partition gumstix_partitions[] = {
0053 {
0054 .name = "Bootloader",
0055 .size = 0x00040000,
0056 .offset = 0,
0057 .mask_flags = MTD_WRITEABLE
0058 } , {
0059 .name = "rootfs",
0060 .size = MTDPART_SIZ_FULL,
0061 .offset = MTDPART_OFS_APPEND
0062 }
0063 };
0064
0065 static struct flash_platform_data gumstix_flash_data = {
0066 .map_name = "cfi_probe",
0067 .parts = gumstix_partitions,
0068 .nr_parts = ARRAY_SIZE(gumstix_partitions),
0069 .width = 2,
0070 };
0071
0072 static struct platform_device gumstix_flash_device = {
0073 .name = "pxa2xx-flash",
0074 .id = 0,
0075 .dev = {
0076 .platform_data = &gumstix_flash_data,
0077 },
0078 .resource = &flash_resource,
0079 .num_resources = 1,
0080 };
0081
0082 static struct platform_device *devices[] __initdata = {
0083 &gumstix_flash_device,
0084 };
0085
0086 #ifdef CONFIG_MMC_PXA
0087 static struct pxamci_platform_data gumstix_mci_platform_data = {
0088 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
0089 };
0090
0091 static void __init gumstix_mmc_init(void)
0092 {
0093 pxa_set_mci_info(&gumstix_mci_platform_data);
0094 }
0095 #else
0096 static void __init gumstix_mmc_init(void)
0097 {
0098 pr_debug("Gumstix mmc disabled\n");
0099 }
0100 #endif
0101
0102 #ifdef CONFIG_USB_PXA25X
0103 static struct gpiod_lookup_table gumstix_gpio_vbus_gpiod_table = {
0104 .dev_id = "gpio-vbus",
0105 .table = {
0106 GPIO_LOOKUP("gpio-pxa", GPIO_GUMSTIX_USB_GPIOn,
0107 "vbus", GPIO_ACTIVE_HIGH),
0108 GPIO_LOOKUP("gpio-pxa", GPIO_GUMSTIX_USB_GPIOx,
0109 "pullup", GPIO_ACTIVE_HIGH),
0110 { },
0111 },
0112 };
0113
0114 static struct platform_device gumstix_gpio_vbus = {
0115 .name = "gpio-vbus",
0116 .id = -1,
0117 };
0118
0119 static void __init gumstix_udc_init(void)
0120 {
0121 gpiod_add_lookup_table(&gumstix_gpio_vbus_gpiod_table);
0122 platform_device_register(&gumstix_gpio_vbus);
0123 }
0124 #else
0125 static void gumstix_udc_init(void)
0126 {
0127 pr_debug("Gumstix udc is disabled\n");
0128 }
0129 #endif
0130
0131 #ifdef CONFIG_BT
0132
0133
0134
0135 static void gumstix_setup_bt_clock(void)
0136 {
0137 int timeout = 500;
0138
0139 if (!(readl(OSCC) & OSCC_OOK))
0140 pr_warn("32kHz clock was not on. Bootloader may need to be updated\n");
0141 else
0142 return;
0143
0144 writel(readl(OSCC) | OSCC_OON, OSCC);
0145 do {
0146 if (readl(OSCC) & OSCC_OOK)
0147 break;
0148 udelay(1);
0149 } while (--timeout);
0150 if (!timeout)
0151 pr_err("Failed to start 32kHz clock\n");
0152 }
0153
0154 static void __init gumstix_bluetooth_init(void)
0155 {
0156 int err;
0157
0158 gumstix_setup_bt_clock();
0159
0160 err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST");
0161 if (err) {
0162 pr_err("gumstix: failed request gpio for bluetooth reset\n");
0163 return;
0164 }
0165
0166 err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1);
0167 if (err) {
0168 pr_err("gumstix: can't reset bluetooth\n");
0169 return;
0170 }
0171 gpio_set_value(GPIO_GUMSTIX_BTRESET, 0);
0172 udelay(100);
0173 gpio_set_value(GPIO_GUMSTIX_BTRESET, 1);
0174 }
0175 #else
0176 static void gumstix_bluetooth_init(void)
0177 {
0178 pr_debug("Gumstix Bluetooth is disabled\n");
0179 }
0180 #endif
0181
0182 static unsigned long gumstix_pin_config[] __initdata = {
0183 GPIO12_32KHz,
0184
0185 GPIO42_HWUART_RXD,
0186 GPIO43_HWUART_TXD,
0187 GPIO44_HWUART_CTS,
0188 GPIO45_HWUART_RTS,
0189
0190 GPIO6_MMC_CLK,
0191 GPIO53_MMC_CLK,
0192 GPIO8_MMC_CS0,
0193 };
0194
0195 int __attribute__((weak)) am200_init(void)
0196 {
0197 return 0;
0198 }
0199
0200 int __attribute__((weak)) am300_init(void)
0201 {
0202 return 0;
0203 }
0204
0205 static void __init carrier_board_init(void)
0206 {
0207
0208
0209
0210
0211 am200_init();
0212 am300_init();
0213 }
0214
0215 static void __init gumstix_init(void)
0216 {
0217 pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config));
0218
0219 pxa_set_ffuart_info(NULL);
0220 pxa_set_btuart_info(NULL);
0221 pxa_set_stuart_info(NULL);
0222 pxa_set_hwuart_info(NULL);
0223
0224 gumstix_bluetooth_init();
0225 gumstix_udc_init();
0226 gumstix_mmc_init();
0227 (void) platform_add_devices(devices, ARRAY_SIZE(devices));
0228 carrier_board_init();
0229 }
0230
0231 MACHINE_START(GUMSTIX, "Gumstix")
0232 .atag_offset = 0x100,
0233 .map_io = pxa25x_map_io,
0234 .nr_irqs = PXA_NR_IRQS,
0235 .init_irq = pxa25x_init_irq,
0236 .handle_irq = pxa25x_handle_irq,
0237 .init_time = pxa_timer_init,
0238 .init_machine = gumstix_init,
0239 .restart = pxa_restart,
0240 MACHINE_END