~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/mips/sibyte/swarm/platform.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 #include <linux/err.h>
  3 #include <linux/kernel.h>
  4 #include <linux/init.h>
  5 #include <linux/io.h>
  6 #include <linux/platform_device.h>
  7 #include <linux/ata_platform.h>
  8 
  9 #include <asm/sibyte/board.h>
 10 #include <asm/sibyte/sb1250_genbus.h>
 11 #include <asm/sibyte/sb1250_regs.h>
 12 
 13 #if defined(CONFIG_SIBYTE_SWARM) || defined(CONFIG_SIBYTE_LITTLESUR)
 14 
 15 #define DRV_NAME        "pata-swarm"
 16 
 17 #define SWARM_IDE_SHIFT 5
 18 #define SWARM_IDE_BASE  0x1f0
 19 #define SWARM_IDE_CTRL  0x3f6
 20 
 21 static struct resource swarm_pata_resource[] = {
 22         {
 23                 .name   = "Swarm GenBus IDE",
 24                 .flags  = IORESOURCE_MEM,
 25         }, {
 26                 .name   = "Swarm GenBus IDE",
 27                 .flags  = IORESOURCE_MEM,
 28         }, {
 29                 .name   = "Swarm GenBus IDE",
 30                 .flags  = IORESOURCE_IRQ,
 31                 .start  = K_INT_GB_IDE,
 32                 .end    = K_INT_GB_IDE,
 33         },
 34 };
 35 
 36 static struct pata_platform_info pata_platform_data = {
 37         .ioport_shift   = SWARM_IDE_SHIFT,
 38 };
 39 
 40 static struct platform_device swarm_pata_device = {
 41         .name           = "pata_platform",
 42         .id             = -1,
 43         .resource       = swarm_pata_resource,
 44         .num_resources  = ARRAY_SIZE(swarm_pata_resource),
 45         .dev  = {
 46                 .platform_data          = &pata_platform_data,
 47                 .coherent_dma_mask      = ~0,   /* grumble */
 48         },
 49 };
 50 
 51 static int __init swarm_pata_init(void)
 52 {
 53         u8 __iomem *base;
 54         phys_addr_t offset, size;
 55         struct resource *r;
 56 
 57         if (!SIBYTE_HAVE_IDE)
 58                 return -ENODEV;
 59 
 60         base = ioremap(A_IO_EXT_BASE, 0x800);
 61         offset = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_START_ADDR, IDE_CS));
 62         size = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_MULT_SIZE, IDE_CS));
 63         iounmap(base);
 64 
 65         offset = G_IO_START_ADDR(offset) << S_IO_ADDRBASE;
 66         size = (G_IO_MULT_SIZE(size) + 1) << S_IO_REGSIZE;
 67         if (offset < A_PHYS_GENBUS || offset >= A_PHYS_GENBUS_END) {
 68                 pr_info(DRV_NAME ": PATA interface at GenBus disabled\n");
 69 
 70                 return -EBUSY;
 71         }
 72 
 73         pr_info(DRV_NAME ": PATA interface at GenBus slot %i\n", IDE_CS);
 74 
 75         r = swarm_pata_resource;
 76         r[0].start = offset + (SWARM_IDE_BASE << SWARM_IDE_SHIFT);
 77         r[0].end   = offset + ((SWARM_IDE_BASE + 8) << SWARM_IDE_SHIFT) - 1;
 78         r[1].start = offset + (SWARM_IDE_CTRL << SWARM_IDE_SHIFT);
 79         r[1].end   = offset + ((SWARM_IDE_CTRL + 1) << SWARM_IDE_SHIFT) - 1;
 80 
 81         return platform_device_register(&swarm_pata_device);
 82 }
 83 
 84 device_initcall(swarm_pata_init);
 85 
 86 #endif /* defined(CONFIG_SIBYTE_SWARM) || defined(CONFIG_SIBYTE_LITTLESUR) */
 87 
 88 #define sb1250_dev_struct(num) \
 89         static struct resource sb1250_res##num = {              \
 90                 .name = "SB1250 MAC " __stringify(num),         \
 91                 .flags = IORESOURCE_MEM,                        \
 92                 .start = A_MAC_CHANNEL_BASE(num),               \
 93                 .end = A_MAC_CHANNEL_BASE(num + 1) - 1,         \
 94         };\
 95         static struct platform_device sb1250_dev##num = {       \
 96                 .name = "sb1250-mac",                           \
 97                 .id = num,                                      \
 98                 .resource = &sb1250_res##num,                   \
 99                 .num_resources = 1,                             \
100         }
101 
102 sb1250_dev_struct(0);
103 sb1250_dev_struct(1);
104 sb1250_dev_struct(2);
105 sb1250_dev_struct(3);
106 
107 static struct platform_device *sb1250_devs[] __initdata = {
108         &sb1250_dev0,
109         &sb1250_dev1,
110         &sb1250_dev2,
111         &sb1250_dev3,
112 };
113 
114 static int __init sb1250_device_init(void)
115 {
116         int ret;
117 
118         /* Set the number of available units based on the SOC type.  */
119         switch (soc_type) {
120         case K_SYS_SOC_TYPE_BCM1250:
121         case K_SYS_SOC_TYPE_BCM1250_ALT:
122                 ret = platform_add_devices(sb1250_devs, 3);
123                 break;
124         case K_SYS_SOC_TYPE_BCM1120:
125         case K_SYS_SOC_TYPE_BCM1125:
126         case K_SYS_SOC_TYPE_BCM1125H:
127         case K_SYS_SOC_TYPE_BCM1250_ALT2:       /* Hybrid */
128                 ret = platform_add_devices(sb1250_devs, 2);
129                 break;
130         case K_SYS_SOC_TYPE_BCM1x55:
131         case K_SYS_SOC_TYPE_BCM1x80:
132                 ret = platform_add_devices(sb1250_devs, 4);
133                 break;
134         default:
135                 ret = -ENODEV;
136                 break;
137         }
138         return ret;
139 }
140 device_initcall(sb1250_device_init);
141 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php