Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]
  1 /*
  2  *  Copyright (C) 2000 Deep Blue Solutions Ltd
  3  *  Copyright (C) 2002 Shane Nay (shane@minirl.com)
  4  *  Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  5  *
  6  * This program is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU General Public License as published by
  8  * the Free Software Foundation; either version 2 of the License, or
  9  * (at your option) any later version.
 10  *
 11  * This program is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14  * GNU General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU General Public License
 17  * along with this program; if not, write to the Free Software
 18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 19  */
 20 
 21 #include <linux/types.h>
 22 #include <linux/init.h>
 23 #include <linux/kernel.h>
 24 #include <linux/memory.h>
 25 #include <linux/platform_device.h>
 26 #include <linux/gpio.h>
 27 #include <linux/smsc911x.h>
 28 
 29 #include <mach/hardware.h>
 30 #include <asm/mach-types.h>
 31 #include <asm/mach/arch.h>
 32 #include <asm/mach/time.h>
 33 #include <asm/mach/map.h>
 34 #include <mach/common.h>
 35 #include <asm/page.h>
 36 #include <asm/setup.h>
 37 #include <mach/board-mx31lite.h>
 38 #include <mach/imx-uart.h>
 39 #include <mach/iomux-mx3.h>
 40 #include <mach/irqs.h>
 41 #include <mach/mxc_nand.h>
 42 #include "devices.h"
 43 
 44 /*
 45  * This file contains the board-specific initialization routines.
 46  */
 47 
 48 static unsigned int mx31lite_pins[] = {
 49         /* UART1 */
 50         MX31_PIN_CTS1__CTS1,
 51         MX31_PIN_RTS1__RTS1,
 52         MX31_PIN_TXD1__TXD1,
 53         MX31_PIN_RXD1__RXD1,
 54         /* LAN9117 IRQ pin */
 55         IOMUX_MODE(MX31_PIN_SFS6, IOMUX_CONFIG_GPIO),
 56 };
 57 
 58 static struct imxuart_platform_data uart_pdata = {
 59         .flags = IMXUART_HAVE_RTSCTS,
 60 };
 61 
 62 static struct mxc_nand_platform_data mx31lite_nand_board_info = {
 63         .width = 1,
 64         .hw_ecc = 1,
 65 };
 66 
 67 static struct smsc911x_platform_config smsc911x_config = {
 68         .irq_polarity   = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
 69         .irq_type       = SMSC911X_IRQ_TYPE_PUSH_PULL,
 70         .flags          = SMSC911X_USE_16BIT,
 71 };
 72 
 73 static struct resource smsc911x_resources[] = {
 74         [0] = {
 75                 .start          = CS4_BASE_ADDR,
 76                 .end            = CS4_BASE_ADDR + 0x100,
 77                 .flags          = IORESOURCE_MEM,
 78         },
 79         [1] = {
 80                 .start          = IOMUX_TO_IRQ(MX31_PIN_SFS6),
 81                 .end            = IOMUX_TO_IRQ(MX31_PIN_SFS6),
 82                 .flags          = IORESOURCE_IRQ,
 83         },
 84 };
 85 
 86 static struct platform_device smsc911x_device = {
 87         .name           = "smsc911x",
 88         .id             = -1,
 89         .num_resources  = ARRAY_SIZE(smsc911x_resources),
 90         .resource       = smsc911x_resources,
 91         .dev            = {
 92                 .platform_data = &smsc911x_config,
 93         },
 94 };
 95 
 96 /*
 97  * This structure defines the MX31 memory map.
 98  */
 99 static struct map_desc mx31lite_io_desc[] __initdata = {
100         {
101                 .virtual = SPBA0_BASE_ADDR_VIRT,
102                 .pfn = __phys_to_pfn(SPBA0_BASE_ADDR),
103                 .length = SPBA0_SIZE,
104                 .type = MT_DEVICE_NONSHARED
105         }, {
106                 .virtual = CS4_BASE_ADDR_VIRT,
107                 .pfn = __phys_to_pfn(CS4_BASE_ADDR),
108                 .length = CS4_SIZE,
109                 .type = MT_DEVICE
110         }
111 };
112 
113 /*
114  * Set up static virtual mappings.
115  */
116 void __init mx31lite_map_io(void)
117 {
118         mx31_map_io();
119         iotable_init(mx31lite_io_desc, ARRAY_SIZE(mx31lite_io_desc));
120 }
121 
122 /*
123  * Board specific initialization.
124  */
125 static void __init mxc_board_init(void)
126 {
127         int ret;
128 
129         mxc_iomux_setup_multiple_pins(mx31lite_pins, ARRAY_SIZE(mx31lite_pins),
130                                       "mx31lite");
131 
132         mxc_register_device(&mxc_uart_device0, &uart_pdata);
133         mxc_register_device(&mxc_nand_device, &mx31lite_nand_board_info);
134 
135         /* SMSC9117 IRQ pin */
136         ret = gpio_request(IOMUX_TO_GPIO(MX31_PIN_SFS6), "sms9117-irq");
137         if (ret)
138                 pr_warning("could not get LAN irq gpio\n");
139         else {
140                 gpio_direction_input(IOMUX_TO_GPIO(MX31_PIN_SFS6));
141                 platform_device_register(&smsc911x_device);
142         }
143 }
144 
145 static void __init mx31lite_timer_init(void)
146 {
147         mx31_clocks_init(26000000);
148 }
149 
150 struct sys_timer mx31lite_timer = {
151         .init   = mx31lite_timer_init,
152 };
153 
154 /*
155  * The following uses standard kernel macros defined in arch.h in order to
156  * initialize __mach_desc_MX31LITE data structure.
157  */
158 
159 MACHINE_START(MX31LITE, "LogicPD MX31 LITEKIT")
160         /* Maintainer: Freescale Semiconductor, Inc. */
161         .phys_io        = AIPS1_BASE_ADDR,
162         .io_pg_offst    = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
163         .boot_params    = PHYS_OFFSET + 0x100,
164         .map_io         = mx31lite_map_io,
165         .init_irq       = mxc_init_irq,
166         .init_machine   = mxc_board_init,
167         .timer          = &mx31lite_timer,
168 MACHINE_END
169 
  This page was automatically generated by the LXR engine.