source: branches/backfire/target/linux/lantiq/patches-2.6.32/0005-MIPS-Lantiq-Add-platform-device-support.patch @ 27546

Last change on this file since 27546 was 27546, checked in by blogic, 5 years ago

add new lantiq target

File size: 9.1 KB
  • arch/mips/lantiq/Makefile

    From 09e57348261c1ae0ff89c68679126fc76a28b2a2 Mon Sep 17 00:00:00 2001
    From: John Crispin <blogic@openwrt.org>
    Date: Wed, 30 Mar 2011 09:27:53 +0200
    Subject: [PATCH 05/13] MIPS: Lantiq: Add platform device support
    
    This patch adds the wrappers for registering our platform devices.
    
    Signed-off-by: John Crispin <blogic@openwrt.org>
    Signed-off-by: Ralph Hempel <ralph.hempel@lantiq.com>
    Cc: linux-mips@linux-mips.org
    Patchwork: https://patchwork.linux-mips.org/patch/2254/
    Patchwork: https://patchwork.linux-mips.org/patch/2360/
    Patchwork: https://patchwork.linux-mips.org/patch/2359/
    Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
    ---
     arch/mips/lantiq/Makefile       |    2 +-
     arch/mips/lantiq/devices.c      |  122 +++++++++++++++++++++++++++++++++++++++
     arch/mips/lantiq/devices.h      |   23 +++++++
     arch/mips/lantiq/xway/Makefile  |    2 +-
     arch/mips/lantiq/xway/devices.c |   98 +++++++++++++++++++++++++++++++
     arch/mips/lantiq/xway/devices.h |   18 ++++++
     6 files changed, 263 insertions(+), 2 deletions(-)
     create mode 100644 arch/mips/lantiq/devices.c
     create mode 100644 arch/mips/lantiq/devices.h
     create mode 100644 arch/mips/lantiq/xway/devices.c
     create mode 100644 arch/mips/lantiq/xway/devices.h
    
    diff --git a/arch/mips/lantiq/Makefile b/arch/mips/lantiq/Makefile
    index a268391..e5dae0e 100644
    a b  
    44# under the terms of the GNU General Public License version 2 as published 
    55# by the Free Software Foundation. 
    66 
    7 obj-y := irq.o setup.o clk.o prom.o 
     7obj-y := irq.o setup.o clk.o prom.o devices.o 
    88 
    99obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 
    1010 
  • new file arch/mips/lantiq/devices.c

    diff --git a/arch/mips/lantiq/devices.c b/arch/mips/lantiq/devices.c
    new file mode 100644
    index 0000000..7b82c34
    - +  
     1/* 
     2 *  This program is free software; you can redistribute it and/or modify it 
     3 *  under the terms of the GNU General Public License version 2 as published 
     4 *  by the Free Software Foundation. 
     5 * 
     6 *  Copyright (C) 2010 John Crispin <blogic@openwrt.org> 
     7 */ 
     8 
     9#include <linux/init.h> 
     10#include <linux/module.h> 
     11#include <linux/types.h> 
     12#include <linux/string.h> 
     13#include <linux/kernel.h> 
     14#include <linux/reboot.h> 
     15#include <linux/platform_device.h> 
     16#include <linux/leds.h> 
     17#include <linux/etherdevice.h> 
     18#include <linux/reboot.h> 
     19#include <linux/time.h> 
     20#include <linux/io.h> 
     21#include <linux/gpio.h> 
     22#include <linux/leds.h> 
     23 
     24#include <asm/bootinfo.h> 
     25#include <asm/irq.h> 
     26 
     27#include <lantiq_soc.h> 
     28 
     29#include "devices.h" 
     30 
     31/* nor flash */ 
     32static struct resource ltq_nor_resource = { 
     33        .name   = "nor", 
     34        .start  = LTQ_FLASH_START, 
     35        .end    = LTQ_FLASH_START + LTQ_FLASH_MAX - 1, 
     36        .flags  = IORESOURCE_MEM, 
     37}; 
     38 
     39static struct platform_device ltq_nor = { 
     40        .name           = "ltq_nor", 
     41        .resource       = &ltq_nor_resource, 
     42        .num_resources  = 1, 
     43}; 
     44 
     45void __init ltq_register_nor(struct physmap_flash_data *data) 
     46{ 
     47        ltq_nor.dev.platform_data = data; 
     48        platform_device_register(&ltq_nor); 
     49} 
     50 
     51/* watchdog */ 
     52static struct resource ltq_wdt_resource = { 
     53        .name   = "watchdog", 
     54        .start  = LTQ_WDT_BASE_ADDR, 
     55        .end    = LTQ_WDT_BASE_ADDR + LTQ_WDT_SIZE - 1, 
     56        .flags  = IORESOURCE_MEM, 
     57}; 
     58 
     59void __init ltq_register_wdt(void) 
     60{ 
     61        platform_device_register_simple("ltq_wdt", 0, &ltq_wdt_resource, 1); 
     62} 
     63 
     64/* asc ports */ 
     65static struct resource ltq_asc0_resources[] = { 
     66        { 
     67                .name   = "asc0", 
     68                .start  = LTQ_ASC0_BASE_ADDR, 
     69                .end    = LTQ_ASC0_BASE_ADDR + LTQ_ASC_SIZE - 1, 
     70                .flags  = IORESOURCE_MEM, 
     71        }, 
     72        IRQ_RES(tx, LTQ_ASC_TIR(0)), 
     73        IRQ_RES(rx, LTQ_ASC_RIR(0)), 
     74        IRQ_RES(err, LTQ_ASC_EIR(0)), 
     75}; 
     76 
     77static struct resource ltq_asc1_resources[] = { 
     78        { 
     79                .name   = "asc1", 
     80                .start  = LTQ_ASC1_BASE_ADDR, 
     81                .end    = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1, 
     82                .flags  = IORESOURCE_MEM, 
     83        }, 
     84        IRQ_RES(tx, LTQ_ASC_TIR(1)), 
     85        IRQ_RES(rx, LTQ_ASC_RIR(1)), 
     86        IRQ_RES(err, LTQ_ASC_EIR(1)), 
     87}; 
     88 
     89void __init ltq_register_asc(int port) 
     90{ 
     91        switch (port) { 
     92        case 0: 
     93                platform_device_register_simple("ltq_asc", 0, 
     94                        ltq_asc0_resources, ARRAY_SIZE(ltq_asc0_resources)); 
     95                break; 
     96        case 1: 
     97                platform_device_register_simple("ltq_asc", 1, 
     98                        ltq_asc1_resources, ARRAY_SIZE(ltq_asc1_resources)); 
     99                break; 
     100        default: 
     101                break; 
     102        } 
     103} 
     104 
     105#ifdef CONFIG_PCI 
     106/* pci */ 
     107static struct platform_device ltq_pci = { 
     108        .name           = "ltq_pci", 
     109        .num_resources  = 0, 
     110}; 
     111 
     112void __init ltq_register_pci(struct ltq_pci_data *data) 
     113{ 
     114        ltq_pci.dev.platform_data = data; 
     115        platform_device_register(&ltq_pci); 
     116} 
     117#else 
     118void __init ltq_register_pci(struct ltq_pci_data *data) 
     119{ 
     120        pr_err("kernel is compiled without PCI support\n"); 
     121} 
     122#endif 
  • new file arch/mips/lantiq/devices.h

    diff --git a/arch/mips/lantiq/devices.h b/arch/mips/lantiq/devices.h
    new file mode 100644
    index 0000000..2947bb1
    - +  
     1/* 
     2 *  This program is free software; you can redistribute it and/or modify it 
     3 *  under the terms of the GNU General Public License version 2 as published 
     4 *  by the Free Software Foundation. 
     5 * 
     6 *  Copyright (C) 2010 John Crispin <blogic@openwrt.org> 
     7 */ 
     8 
     9#ifndef _LTQ_DEVICES_H__ 
     10#define _LTQ_DEVICES_H__ 
     11 
     12#include <lantiq_platform.h> 
     13#include <linux/mtd/physmap.h> 
     14 
     15#define IRQ_RES(resname, irq) \ 
     16        {.name = #resname, .start = (irq), .flags = IORESOURCE_IRQ} 
     17 
     18extern void ltq_register_nor(struct physmap_flash_data *data); 
     19extern void ltq_register_wdt(void); 
     20extern void ltq_register_asc(int port); 
     21extern void ltq_register_pci(struct ltq_pci_data *data); 
     22 
     23#endif 
  • arch/mips/lantiq/xway/Makefile

    diff --git a/arch/mips/lantiq/xway/Makefile b/arch/mips/lantiq/xway/Makefile
    index 9c85ff9..74ce438 100644
    a b  
    1 obj-y := pmu.o ebu.o reset.o gpio.o 
     1obj-y := pmu.o ebu.o reset.o gpio.o devices.o 
    22 
    33obj-$(CONFIG_SOC_XWAY) += clk-xway.o prom-xway.o 
    44obj-$(CONFIG_SOC_AMAZON_SE) += clk-ase.o prom-ase.o 
  • new file arch/mips/lantiq/xway/devices.c

    diff --git a/arch/mips/lantiq/xway/devices.c b/arch/mips/lantiq/xway/devices.c
    new file mode 100644
    index 0000000..a71b3b5
    - +  
     1/* 
     2 *  This program is free software; you can redistribute it and/or modify it 
     3 *  under the terms of the GNU General Public License version 2 as published 
     4 *  by the Free Software Foundation. 
     5 * 
     6 *  Copyright (C) 2010 John Crispin <blogic@openwrt.org> 
     7 */ 
     8 
     9#include <linux/init.h> 
     10#include <linux/module.h> 
     11#include <linux/types.h> 
     12#include <linux/string.h> 
     13#include <linux/mtd/physmap.h> 
     14#include <linux/kernel.h> 
     15#include <linux/reboot.h> 
     16#include <linux/platform_device.h> 
     17#include <linux/leds.h> 
     18#include <linux/etherdevice.h> 
     19#include <linux/reboot.h> 
     20#include <linux/time.h> 
     21#include <linux/io.h> 
     22#include <linux/gpio.h> 
     23#include <linux/leds.h> 
     24 
     25#include <asm/bootinfo.h> 
     26#include <asm/irq.h> 
     27 
     28#include <lantiq_soc.h> 
     29#include <lantiq_irq.h> 
     30#include <lantiq_platform.h> 
     31 
     32#include "devices.h" 
     33 
     34/* gpio */ 
     35static struct resource ltq_gpio_resource[] = { 
     36        { 
     37                .name   = "gpio0", 
     38                .start  = LTQ_GPIO0_BASE_ADDR, 
     39                .end    = LTQ_GPIO0_BASE_ADDR + LTQ_GPIO_SIZE - 1, 
     40                .flags  = IORESOURCE_MEM, 
     41        }, { 
     42                .name   = "gpio1", 
     43                .start  = LTQ_GPIO1_BASE_ADDR, 
     44                .end    = LTQ_GPIO1_BASE_ADDR + LTQ_GPIO_SIZE - 1, 
     45                .flags  = IORESOURCE_MEM, 
     46        }, { 
     47                .name   = "gpio2", 
     48                .start  = LTQ_GPIO2_BASE_ADDR, 
     49                .end    = LTQ_GPIO2_BASE_ADDR + LTQ_GPIO_SIZE - 1, 
     50                .flags  = IORESOURCE_MEM, 
     51        } 
     52}; 
     53 
     54void __init ltq_register_gpio(void) 
     55{ 
     56        platform_device_register_simple("ltq_gpio", 0, 
     57                &ltq_gpio_resource[0], 1); 
     58        platform_device_register_simple("ltq_gpio", 1, 
     59                &ltq_gpio_resource[1], 1); 
     60 
     61        /* AR9 and VR9 have an extra gpio block */ 
     62        if (ltq_is_ar9() || ltq_is_vr9()) { 
     63                platform_device_register_simple("ltq_gpio", 2, 
     64                        &ltq_gpio_resource[2], 1); 
     65        } 
     66} 
     67 
     68/* serial to parallel conversion */ 
     69static struct resource ltq_stp_resource = { 
     70        .name   = "stp", 
     71        .start  = LTQ_STP_BASE_ADDR, 
     72        .end    = LTQ_STP_BASE_ADDR + LTQ_STP_SIZE - 1, 
     73        .flags  = IORESOURCE_MEM, 
     74}; 
     75 
     76void __init ltq_register_gpio_stp(void) 
     77{ 
     78        platform_device_register_simple("ltq_stp", 0, &ltq_stp_resource, 1); 
     79} 
     80 
     81/* asc ports - amazon se has its own serial mapping */ 
     82static struct resource ltq_ase_asc_resources[] = { 
     83        { 
     84                .name   = "asc0", 
     85                .start  = LTQ_ASC1_BASE_ADDR, 
     86                .end    = LTQ_ASC1_BASE_ADDR + LTQ_ASC_SIZE - 1, 
     87                .flags  = IORESOURCE_MEM, 
     88        }, 
     89        IRQ_RES(tx, LTQ_ASC_ASE_TIR), 
     90        IRQ_RES(rx, LTQ_ASC_ASE_RIR), 
     91        IRQ_RES(err, LTQ_ASC_ASE_EIR), 
     92}; 
     93 
     94void __init ltq_register_ase_asc(void) 
     95{ 
     96        platform_device_register_simple("ltq_asc", 0, 
     97                ltq_ase_asc_resources, ARRAY_SIZE(ltq_ase_asc_resources)); 
     98} 
  • new file arch/mips/lantiq/xway/devices.h

    diff --git a/arch/mips/lantiq/xway/devices.h b/arch/mips/lantiq/xway/devices.h
    new file mode 100644
    index 0000000..51f56b5
    - +  
     1/* 
     2 *  This program is free software; you can redistribute it and/or modify it 
     3 *  under the terms of the GNU General Public License version 2 as published 
     4 *  by the Free Software Foundation. 
     5 * 
     6 *  Copyright (C) 2010 John Crispin <blogic@openwrt.org> 
     7 */ 
     8 
     9#ifndef _LTQ_DEVICES_XWAY_H__ 
     10#define _LTQ_DEVICES_XWAY_H__ 
     11 
     12#include "../devices.h" 
     13 
     14extern void ltq_register_gpio(void); 
     15extern void ltq_register_gpio_stp(void); 
     16extern void ltq_register_ase_asc(void); 
     17 
     18#endif 
Note: See TracBrowser for help on using the repository browser.