1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * linux/arch/arm/mach-pxa/gumstix.c 4 * 5 * Support for the Gumstix motherboards. 6 * 7 * Original Author: Craig Hughes 8 * Created: Feb 14, 2008 9 * Copyright: Craig Hughes 10 * 11 * Implemented based on lubbock.c by Nicolas Pitre and code from Craig 12 * Hughes 13 */ 14 15 #include <linux/module.h> 16 #include <linux/kernel.h> 17 #include <linux/init.h> 18 #include <linux/platform_device.h> 19 #include <linux/interrupt.h> 20 #include <linux/delay.h> 21 #include <linux/mtd/mtd.h> 22 #include <linux/mtd/partitions.h> 23 #include <linux/gpio/machine.h> 24 #include <linux/gpio.h> 25 #include <linux/err.h> 26 #include <linux/clk.h> 27 28 #include <asm/setup.h> 29 #include <asm/page.h> 30 #include <asm/mach-types.h> 31 #include <asm/irq.h> 32 #include <linux/sizes.h> 33 34 #include <asm/mach/arch.h> 35 #include <asm/mach/map.h> 36 #include <asm/mach/irq.h> 37 #include <asm/mach/flash.h> 38 39 #include "pxa25x.h" 40 #include <linux/platform_data/mmc-pxamci.h> 41 #include "udc.h" 42 #include "gumstix.h" 43 44 #include "generic.h" 45 46 static struct resource flash_resource = { 47 .start = 0x00000000, 48 .end = SZ_64M - 1, 49 .flags = IORESOURCE_MEM, 50 }; 51 52 static struct mtd_partition gumstix_partitions[] = { 53 { 54 .name = "Bootloader", 55 .size = 0x00040000, 56 .offset = 0, 57 .mask_flags = MTD_WRITEABLE /* force read-only */ 58 } , { 59 .name = "rootfs", 60 .size = MTDPART_SIZ_FULL, 61 .offset = MTDPART_OFS_APPEND 62 } 63 }; 64 65 static struct flash_platform_data gumstix_flash_data = { 66 .map_name = "cfi_probe", 67 .parts = gumstix_partitions, 68 .nr_parts = ARRAY_SIZE(gumstix_partitions), 69 .width = 2, 70 }; 71 72 static struct platform_device gumstix_flash_device = { 73 .name = "pxa2xx-flash", 74 .id = 0, 75 .dev = { 76 .platform_data = &gumstix_flash_data, 77 }, 78 .resource = &flash_resource, 79 .num_resources = 1, 80 }; 81 82 static struct platform_device *devices[] __initdata = { 83 &gumstix_flash_device, 84 }; 85 86 #ifdef CONFIG_MMC_PXA 87 static struct pxamci_platform_data gumstix_mci_platform_data = { 88 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 89 }; 90 91 static void __init gumstix_mmc_init(void) 92 { 93 pxa_set_mci_info(&gumstix_mci_platform_data, NULL); 94 } 95 #else 96 static void __init gumstix_mmc_init(void) 97 { 98 pr_debug("Gumstix mmc disabled\n"); 99 } 100 #endif 101 102 #ifdef CONFIG_USB_PXA25X 103 static const struct property_entry spitz_mci_props[] __initconst = { 104 PROPERTY_ENTRY_GPIO("vbus-gpios", &pxa2xx_gpiochip_node, 105 GPIO_GUMSTIX_USB_GPIOn, GPIO_ACTIVE_HIGH), 106 PROPERTY_ENTRY_GPIO("pullup-gpios", &pxa2xx_gpiochip_node, 107 GPIO_GUMSTIX_USB_GPIOx, GPIO_ACTIVE_HIGH), 108 { } 109 }; 110 111 static const struct platform_device_info gumstix_gpio_vbus_info __initconst = { 112 .name = "gpio-vbus", 113 .id = PLATFORM_DEVID_NONE, 114 }; 115 116 static void __init gumstix_udc_init(void) 117 { 118 platform_device_register_full(&gumstix_gpio_vbus_info); 119 } 120 #else 121 static void gumstix_udc_init(void) 122 { 123 pr_debug("Gumstix udc is disabled\n"); 124 } 125 #endif 126 127 #ifdef CONFIG_BT 128 /* Normally, the bootloader would have enabled this 32kHz clock but many 129 ** boards still have u-boot 1.1.4 so we check if it has been turned on and 130 ** if not, we turn it on with a warning message. */ 131 static void gumstix_setup_bt_clock(void) 132 { 133 int timeout = 500; 134 135 if (!(readl(OSCC) & OSCC_OOK)) 136 pr_warn("32kHz clock was not on. Bootloader may need to be updated\n"); 137 else 138 return; 139 140 writel(readl(OSCC) | OSCC_OON, OSCC); 141 do { 142 if (readl(OSCC) & OSCC_OOK) 143 break; 144 udelay(1); 145 } while (--timeout); 146 if (!timeout) 147 pr_err("Failed to start 32kHz clock\n"); 148 } 149 150 static void __init gumstix_bluetooth_init(void) 151 { 152 int err; 153 154 gumstix_setup_bt_clock(); 155 156 err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST"); 157 if (err) { 158 pr_err("gumstix: failed request gpio for bluetooth reset\n"); 159 return; 160 } 161 162 err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1); 163 if (err) { 164 pr_err("gumstix: can't reset bluetooth\n"); 165 return; 166 } 167 gpio_set_value(GPIO_GUMSTIX_BTRESET, 0); 168 udelay(100); 169 gpio_set_value(GPIO_GUMSTIX_BTRESET, 1); 170 } 171 #else 172 static void gumstix_bluetooth_init(void) 173 { 174 pr_debug("Gumstix Bluetooth is disabled\n"); 175 } 176 #endif 177 178 static unsigned long gumstix_pin_config[] __initdata = { 179 GPIO12_32KHz, 180 /* BTUART */ 181 GPIO42_HWUART_RXD, 182 GPIO43_HWUART_TXD, 183 GPIO44_HWUART_CTS, 184 GPIO45_HWUART_RTS, 185 /* MMC */ 186 GPIO6_MMC_CLK, 187 GPIO53_MMC_CLK, 188 GPIO8_MMC_CS0, 189 }; 190 191 int __attribute__((weak)) am200_init(void) 192 { 193 return 0; 194 } 195 196 int __attribute__((weak)) am300_init(void) 197 { 198 return 0; 199 } 200 201 static void __init carrier_board_init(void) 202 { 203 /* 204 * put carrier/expansion board init here if 205 * they cannot be detected programatically 206 */ 207 am200_init(); 208 am300_init(); 209 } 210 211 static void __init gumstix_init(void) 212 { 213 pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config)); 214 215 pxa_set_ffuart_info(NULL); 216 pxa_set_btuart_info(NULL); 217 pxa_set_stuart_info(NULL); 218 pxa_set_hwuart_info(NULL); 219 220 gumstix_bluetooth_init(); 221 gumstix_udc_init(); 222 gumstix_mmc_init(); 223 (void) platform_add_devices(devices, ARRAY_SIZE(devices)); 224 carrier_board_init(); 225 } 226 227 MACHINE_START(GUMSTIX, "Gumstix") 228 .atag_offset = 0x100, /* match u-boot bi_boot_params */ 229 .map_io = pxa25x_map_io, 230 .nr_irqs = PXA_NR_IRQS, 231 .init_irq = pxa25x_init_irq, 232 .init_time = pxa_timer_init, 233 .init_machine = gumstix_init, 234 .restart = pxa_restart, 235 MACHINE_END 236