Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * linux/arch/arm/mach-sa1100/pleb.c
0004  */
0005 
0006 #include <linux/init.h>
0007 #include <linux/kernel.h>
0008 #include <linux/tty.h>
0009 #include <linux/ioport.h>
0010 #include <linux/platform_data/sa11x0-serial.h>
0011 #include <linux/platform_device.h>
0012 #include <linux/irq.h>
0013 #include <linux/io.h>
0014 #include <linux/mtd/partitions.h>
0015 #include <linux/smc91x.h>
0016 
0017 #include <mach/hardware.h>
0018 #include <asm/setup.h>
0019 #include <asm/mach-types.h>
0020 
0021 #include <asm/mach/arch.h>
0022 #include <asm/mach/map.h>
0023 #include <asm/mach/flash.h>
0024 #include <mach/irqs.h>
0025 
0026 #include "generic.h"
0027 
0028 
0029 /*
0030  * Ethernet IRQ mappings
0031  */
0032 
0033 #define PLEB_ETH0_P     (0x20000300)    /* Ethernet 0 in PCMCIA0 IO */
0034 #define PLEB_ETH0_V     (0xf6000300)
0035 
0036 #define GPIO_ETH0_IRQ       GPIO_GPIO(21)
0037 #define GPIO_ETH0_EN        GPIO_GPIO(26)
0038 
0039 #define IRQ_GPIO_ETH0_IRQ   IRQ_GPIO21
0040 
0041 static struct resource smc91x_resources[] = {
0042     [0] = DEFINE_RES_MEM(PLEB_ETH0_P, 0x04000000),
0043 #if 0 /* Autoprobe instead, to get rising/falling edge characteristic right */
0044     [1] = DEFINE_RES_IRQ(IRQ_GPIO_ETH0_IRQ),
0045 #endif
0046 };
0047 
0048 static struct smc91x_platdata smc91x_platdata = {
0049     .flags = SMC91X_USE_16BIT | SMC91X_USE_8BIT | SMC91X_NOWAIT,
0050 };
0051 
0052 static struct platform_device smc91x_device = {
0053     .name       = "smc91x",
0054     .id     = 0,
0055     .num_resources  = ARRAY_SIZE(smc91x_resources),
0056     .resource   = smc91x_resources,
0057     .dev = {
0058         .platform_data  = &smc91x_platdata,
0059     },
0060 };
0061 
0062 static struct platform_device *devices[] __initdata = {
0063     &smc91x_device,
0064 };
0065 
0066 
0067 /*
0068  * Pleb's memory map
0069  * has flash memory (typically 4 or 8 meg) selected by
0070  * the two SA1100 lowest chip select outputs.
0071  */
0072 static struct resource pleb_flash_resources[] = {
0073     [0] = DEFINE_RES_MEM(SA1100_CS0_PHYS, SZ_8M),
0074     [1] = DEFINE_RES_MEM(SA1100_CS1_PHYS, SZ_8M),
0075 };
0076 
0077 
0078 static struct mtd_partition pleb_partitions[] = {
0079     {
0080         .name       = "blob",
0081         .offset     = 0,
0082         .size       = 0x00020000,
0083     }, {
0084         .name       = "kernel",
0085         .offset     = MTDPART_OFS_APPEND,
0086         .size       = 0x000e0000,
0087     }, {
0088         .name       = "rootfs",
0089         .offset     = MTDPART_OFS_APPEND,
0090         .size       = 0x00300000,
0091     }
0092 };
0093 
0094 
0095 static struct flash_platform_data pleb_flash_data = {
0096     .map_name = "cfi_probe",
0097     .parts = pleb_partitions,
0098     .nr_parts = ARRAY_SIZE(pleb_partitions),
0099 };
0100 
0101 
0102 static void __init pleb_init(void)
0103 {
0104     sa11x0_register_mtd(&pleb_flash_data, pleb_flash_resources,
0105                   ARRAY_SIZE(pleb_flash_resources));
0106 
0107 
0108     platform_add_devices(devices, ARRAY_SIZE(devices));
0109 }
0110 
0111 
0112 static void __init pleb_map_io(void)
0113 {
0114     sa1100_map_io();
0115 
0116     sa1100_register_uart(0, 3);
0117     sa1100_register_uart(1, 1);
0118 
0119     GAFR |= (GPIO_UART_TXD | GPIO_UART_RXD);
0120     GPDR |= GPIO_UART_TXD;
0121     GPDR &= ~GPIO_UART_RXD;
0122     PPAR |= PPAR_UPR;
0123 
0124     /*
0125      * Fix expansion memory timing for network card
0126      */
0127     MECR = ((2<<10) | (2<<5) | (2<<0));
0128 
0129     /*
0130      * Enable the SMC ethernet controller
0131      */
0132     GPDR |= GPIO_ETH0_EN;   /* set to output */
0133     GPCR  = GPIO_ETH0_EN;   /* clear MCLK (enable smc) */
0134 
0135     GPDR &= ~GPIO_ETH0_IRQ;
0136 
0137     irq_set_irq_type(GPIO_ETH0_IRQ, IRQ_TYPE_EDGE_FALLING);
0138 }
0139 
0140 MACHINE_START(PLEB, "PLEB")
0141     .map_io     = pleb_map_io,
0142     .nr_irqs    = SA1100_NR_IRQS,
0143     .init_irq   = sa1100_init_irq,
0144     .init_time  = sa1100_timer_init,
0145     .init_machine   = pleb_init,
0146     .init_late  = sa11x0_init_late,
0147     .restart    = sa11x0_restart,
0148 MACHINE_END