linux/arch/mips/emma/markeins/platform.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0-or-later
   2/*
   3 *  Copyright(C) MontaVista Software Inc, 2006
   4 *
   5 *  Author: dmitry pervushin <dpervushin@ru.mvista.com>
   6 */
   7#include <linux/init.h>
   8#include <linux/kernel.h>
   9#include <linux/types.h>
  10#include <linux/ioport.h>
  11#include <linux/serial_8250.h>
  12#include <linux/mtd/physmap.h>
  13
  14#include <asm/cpu.h>
  15#include <asm/bootinfo.h>
  16#include <asm/addrspace.h>
  17#include <asm/time.h>
  18#include <asm/bcache.h>
  19#include <asm/irq.h>
  20#include <asm/reboot.h>
  21#include <asm/traps.h>
  22
  23#include <asm/emma/emma2rh.h>
  24
  25
  26#define I2C_EMMA2RH "emma2rh-iic" /* must be in sync with IIC driver */
  27
  28static struct resource i2c_emma_resources_0[] = {
  29        {
  30                .name   = NULL,
  31                .start  = EMMA2RH_IRQ_PIIC0,
  32                .end    = EMMA2RH_IRQ_PIIC0,
  33                .flags  = IORESOURCE_IRQ
  34        }, {
  35                .name   = NULL,
  36                .start  = EMMA2RH_PIIC0_BASE,
  37                .end    = EMMA2RH_PIIC0_BASE + 0x1000,
  38                .flags  = 0
  39        },
  40};
  41
  42struct resource i2c_emma_resources_1[] = {
  43        {
  44                .name   = NULL,
  45                .start  = EMMA2RH_IRQ_PIIC1,
  46                .end    = EMMA2RH_IRQ_PIIC1,
  47                .flags  = IORESOURCE_IRQ
  48        }, {
  49                .name   = NULL,
  50                .start  = EMMA2RH_PIIC1_BASE,
  51                .end    = EMMA2RH_PIIC1_BASE + 0x1000,
  52                .flags  = 0
  53        },
  54};
  55
  56struct resource i2c_emma_resources_2[] = {
  57        {
  58                .name   = NULL,
  59                .start  = EMMA2RH_IRQ_PIIC2,
  60                .end    = EMMA2RH_IRQ_PIIC2,
  61                .flags  = IORESOURCE_IRQ
  62        }, {
  63                .name   = NULL,
  64                .start  = EMMA2RH_PIIC2_BASE,
  65                .end    = EMMA2RH_PIIC2_BASE + 0x1000,
  66                .flags  = 0
  67        },
  68};
  69
  70struct platform_device i2c_emma_devices[] = {
  71        [0] = {
  72                .name = I2C_EMMA2RH,
  73                .id = 0,
  74                .resource = i2c_emma_resources_0,
  75                .num_resources = ARRAY_SIZE(i2c_emma_resources_0),
  76        },
  77        [1] = {
  78                .name = I2C_EMMA2RH,
  79                .id = 1,
  80                .resource = i2c_emma_resources_1,
  81                .num_resources = ARRAY_SIZE(i2c_emma_resources_1),
  82        },
  83        [2] = {
  84                .name = I2C_EMMA2RH,
  85                .id = 2,
  86                .resource = i2c_emma_resources_2,
  87                .num_resources = ARRAY_SIZE(i2c_emma_resources_2),
  88        },
  89};
  90
  91#define EMMA2RH_SERIAL_CLOCK 18544000
  92#define EMMA2RH_SERIAL_FLAGS UPF_BOOT_AUTOCONF | UPF_SKIP_TEST
  93
  94static struct  plat_serial8250_port platform_serial_ports[] = {
  95        [0] = {
  96                .membase= (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR0_BASE + 3),
  97                .mapbase = EMMA2RH_PFUR0_BASE + 3,
  98                .irq = EMMA2RH_IRQ_PFUR0,
  99                .uartclk = EMMA2RH_SERIAL_CLOCK,
 100                .regshift = 4,
 101                .iotype = UPIO_MEM,
 102                .flags = EMMA2RH_SERIAL_FLAGS,
 103       }, [1] = {
 104                .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR1_BASE + 3),
 105                .mapbase = EMMA2RH_PFUR1_BASE + 3,
 106                .irq = EMMA2RH_IRQ_PFUR1,
 107                .uartclk = EMMA2RH_SERIAL_CLOCK,
 108                .regshift = 4,
 109                .iotype = UPIO_MEM,
 110                .flags = EMMA2RH_SERIAL_FLAGS,
 111       }, [2] = {
 112                .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR2_BASE + 3),
 113                .mapbase = EMMA2RH_PFUR2_BASE + 3,
 114                .irq = EMMA2RH_IRQ_PFUR2,
 115                .uartclk = EMMA2RH_SERIAL_CLOCK,
 116                .regshift = 4,
 117                .iotype = UPIO_MEM,
 118                .flags = EMMA2RH_SERIAL_FLAGS,
 119       }, [3] = {
 120                .flags = 0,
 121       },
 122};
 123
 124static struct  platform_device serial_emma = {
 125        .name = "serial8250",
 126        .dev = {
 127                .platform_data = &platform_serial_ports,
 128        },
 129};
 130
 131static struct mtd_partition markeins_parts[] = {
 132        [0] = {
 133                .name = "RootFS",
 134                .offset = 0x00000000,
 135                .size = 0x00c00000,
 136        },
 137        [1] = {
 138                .name = "boot code area",
 139                .offset = MTDPART_OFS_APPEND,
 140                .size = 0x00100000,
 141        },
 142        [2] = {
 143                .name = "kernel image",
 144                .offset = MTDPART_OFS_APPEND,
 145                .size = 0x00300000,
 146        },
 147        [3] = {
 148                .name = "RootFS2",
 149                .offset = MTDPART_OFS_APPEND,
 150                .size = 0x00c00000,
 151        },
 152        [4] = {
 153                .name = "boot code area2",
 154                .offset = MTDPART_OFS_APPEND,
 155                .size = 0x00100000,
 156        },
 157        [5] = {
 158                .name = "kernel image2",
 159                .offset = MTDPART_OFS_APPEND,
 160                .size = MTDPART_SIZ_FULL,
 161        },
 162};
 163
 164static struct physmap_flash_data markeins_flash_data = {
 165        .width          = 2,
 166        .nr_parts       = ARRAY_SIZE(markeins_parts),
 167        .parts          = markeins_parts
 168};
 169
 170static struct resource markeins_flash_resource = {
 171        .start          = 0x1e000000,
 172        .end            = 0x02000000,
 173        .flags          = IORESOURCE_MEM
 174};
 175
 176static struct platform_device markeins_flash_device = {
 177        .name           = "physmap-flash",
 178        .id             = 0,
 179        .dev            = {
 180                .platform_data  = &markeins_flash_data,
 181        },
 182        .num_resources  = 1,
 183        .resource       = &markeins_flash_resource,
 184};
 185
 186static struct platform_device *devices[] = {
 187        i2c_emma_devices,
 188        i2c_emma_devices + 1,
 189        i2c_emma_devices + 2,
 190        &serial_emma,
 191        &markeins_flash_device,
 192};
 193
 194static int __init platform_devices_setup(void)
 195{
 196        return platform_add_devices(devices, ARRAY_SIZE(devices));
 197}
 198
 199arch_initcall(platform_devices_setup);
 200