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  *  arch/arm/mach-pxa/colibri-pxa3xx.c
  3  *
  4  *  Common functions for all Toradex PXA3xx modules
  5  *
  6  *  Daniel Mack <daniel@caiaq.de>
  7  *
  8  *  This program is free software; you can redistribute it and/or modify
  9  *  it under the terms of the GNU General Public License version 2 as
 10  *  published by the Free Software Foundation.
 11  */
 12 
 13 #include <linux/init.h>
 14 #include <linux/kernel.h>
 15 #include <linux/platform_device.h>
 16 #include <linux/gpio.h>
 17 #include <linux/etherdevice.h>
 18 #include <asm/mach-types.h>
 19 #include <mach/hardware.h>
 20 #include <asm/sizes.h>
 21 #include <asm/mach/arch.h>
 22 #include <asm/mach/irq.h>
 23 #include <mach/pxa3xx-regs.h>
 24 #include <mach/mfp-pxa300.h>
 25 #include <mach/colibri.h>
 26 #include <mach/mmc.h>
 27 #include <mach/pxafb.h>
 28 
 29 #include "generic.h"
 30 #include "devices.h"
 31 
 32 #if defined(CONFIG_AX88796)
 33 #define ETHER_ADDR_LEN 6
 34 static u8 ether_mac_addr[ETHER_ADDR_LEN];
 35 
 36 void __init colibri_pxa3xx_init_eth(struct ax_plat_data *plat_data)
 37 {
 38         int i;
 39         u64 serial = ((u64) system_serial_high << 32) | system_serial_low;
 40 
 41         /*
 42          * If the bootloader passed in a serial boot tag, which contains a
 43          * valid ethernet MAC, pass it to the interface. Toradex ships the
 44          * modules with their own bootloader which provides a valid MAC
 45          * this way.
 46          */
 47 
 48         for (i = 0; i < ETHER_ADDR_LEN; i++) {
 49                 ether_mac_addr[i] = serial & 0xff;
 50                 serial >>= 8;
 51         }
 52 
 53         if (is_valid_ether_addr(ether_mac_addr)) {
 54                 plat_data->flags |= AXFLG_MAC_FROMPLATFORM;
 55                 plat_data->mac_addr = ether_mac_addr;
 56                 printk(KERN_INFO "%s(): taking MAC from serial boot tag\n",
 57                         __func__);
 58         } else {
 59                 plat_data->flags |= AXFLG_MAC_FROMDEV;
 60                 printk(KERN_INFO "%s(): no valid serial boot tag found, "
 61                         "taking MAC from device\n", __func__);
 62         }
 63 }
 64 #endif
 65 
 66 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
 67 static int mmc_detect_pin;
 68 
 69 static int colibri_pxa3xx_mci_init(struct device *dev,
 70                                    irq_handler_t colibri_mmc_detect_int,
 71                                    void *data)
 72 {
 73         int ret;
 74 
 75         ret = gpio_request(mmc_detect_pin, "mmc card detect");
 76         if (ret)
 77                 return ret;
 78 
 79         gpio_direction_input(mmc_detect_pin);
 80         ret = request_irq(gpio_to_irq(mmc_detect_pin), colibri_mmc_detect_int,
 81                           IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
 82                           "MMC card detect", data);
 83         if (ret) {
 84                 gpio_free(mmc_detect_pin);
 85                 return ret;
 86         }
 87 
 88         return 0;
 89 }
 90 
 91 static void colibri_pxa3xx_mci_exit(struct device *dev, void *data)
 92 {
 93         free_irq(mmc_detect_pin, data);
 94         gpio_free(gpio_to_irq(mmc_detect_pin));
 95 }
 96 
 97 static struct pxamci_platform_data colibri_pxa3xx_mci_platform_data = {
 98         .detect_delay   = 20,
 99         .ocr_mask       = MMC_VDD_32_33 | MMC_VDD_33_34,
100         .init           = colibri_pxa3xx_mci_init,
101         .exit           = colibri_pxa3xx_mci_exit,
102 };
103 
104 void __init colibri_pxa3xx_init_mmc(mfp_cfg_t *pins, int len, int detect_pin)
105 {
106         pxa3xx_mfp_config(pins, len);
107         mmc_detect_pin = detect_pin;
108         pxa_set_mci_info(&colibri_pxa3xx_mci_platform_data);
109 }
110 #endif /* CONFIG_MMC_PXA || CONFIG_MMC_PXA_MODULE */
111 
112 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
113 static int lcd_bl_pin;
114 
115 /*
116  * LCD panel (Sharp LQ043T3DX02)
117  */
118 static void colibri_lcd_backlight(int on)
119 {
120         gpio_set_value(lcd_bl_pin, !!on);
121 }
122 
123 static struct pxafb_mode_info sharp_lq43_mode = {
124         .pixclock       = 101936,
125         .xres           = 480,
126         .yres           = 272,
127         .bpp            = 32,
128         .depth          = 18,
129         .hsync_len      = 41,
130         .left_margin    = 2,
131         .right_margin   = 2,
132         .vsync_len      = 10,
133         .upper_margin   = 2,
134         .lower_margin   = 2,
135         .sync           = 0,
136         .cmap_greyscale = 0,
137 };
138 
139 static struct pxafb_mach_info sharp_lq43_info = {
140         .modes          = &sharp_lq43_mode,
141         .num_modes      = 1,
142         .cmap_inverse   = 0,
143         .cmap_static    = 0,
144         .lcd_conn       = LCD_COLOR_TFT_18BPP,
145         .pxafb_backlight_power = colibri_lcd_backlight,
146 };
147 
148 void __init colibri_pxa3xx_init_lcd(int bl_pin)
149 {
150         lcd_bl_pin = bl_pin;
151         gpio_request(bl_pin, "lcd backlight");
152         gpio_direction_output(bl_pin, 0);
153         set_pxa_fb_info(&sharp_lq43_info);
154 }
155 #endif
156 
157 
  This page was automatically generated by the LXR engine.