Daniel Mack | acb3655 | 2009-03-23 02:04:17 +0100 | [diff] [blame] | 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> |
Daniel Mack | 22a0200 | 2009-04-02 08:33:14 +0200 | [diff] [blame] | 17 | #include <linux/etherdevice.h> |
Daniel Mack | acb3655 | 2009-03-23 02:04:17 +0100 | [diff] [blame] | 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> |
Daniel Mack | 91fcfb9 | 2009-03-23 02:04:19 +0100 | [diff] [blame] | 27 | #include <mach/pxafb.h> |
Haojian Zhuang | 82b95ec | 2009-09-10 13:55:23 +0800 | [diff] [blame] | 28 | #include <plat/pxa3xx_nand.h> |
Daniel Mack | acb3655 | 2009-03-23 02:04:17 +0100 | [diff] [blame] | 29 | |
| 30 | #include "generic.h" |
| 31 | #include "devices.h" |
| 32 | |
Daniel Mack | 22a0200 | 2009-04-02 08:33:14 +0200 | [diff] [blame] | 33 | #if defined(CONFIG_AX88796) |
| 34 | #define ETHER_ADDR_LEN 6 |
| 35 | static u8 ether_mac_addr[ETHER_ADDR_LEN]; |
| 36 | |
| 37 | void __init colibri_pxa3xx_init_eth(struct ax_plat_data *plat_data) |
| 38 | { |
| 39 | int i; |
| 40 | u64 serial = ((u64) system_serial_high << 32) | system_serial_low; |
| 41 | |
| 42 | /* |
| 43 | * If the bootloader passed in a serial boot tag, which contains a |
| 44 | * valid ethernet MAC, pass it to the interface. Toradex ships the |
| 45 | * modules with their own bootloader which provides a valid MAC |
| 46 | * this way. |
| 47 | */ |
| 48 | |
| 49 | for (i = 0; i < ETHER_ADDR_LEN; i++) { |
| 50 | ether_mac_addr[i] = serial & 0xff; |
| 51 | serial >>= 8; |
| 52 | } |
| 53 | |
| 54 | if (is_valid_ether_addr(ether_mac_addr)) { |
| 55 | plat_data->flags |= AXFLG_MAC_FROMPLATFORM; |
| 56 | plat_data->mac_addr = ether_mac_addr; |
| 57 | printk(KERN_INFO "%s(): taking MAC from serial boot tag\n", |
| 58 | __func__); |
| 59 | } else { |
| 60 | plat_data->flags |= AXFLG_MAC_FROMDEV; |
| 61 | printk(KERN_INFO "%s(): no valid serial boot tag found, " |
| 62 | "taking MAC from device\n", __func__); |
| 63 | } |
| 64 | } |
| 65 | #endif |
| 66 | |
Daniel Mack | 91fcfb9 | 2009-03-23 02:04:19 +0100 | [diff] [blame] | 67 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
| 68 | static int lcd_bl_pin; |
| 69 | |
| 70 | /* |
| 71 | * LCD panel (Sharp LQ043T3DX02) |
| 72 | */ |
| 73 | static void colibri_lcd_backlight(int on) |
| 74 | { |
| 75 | gpio_set_value(lcd_bl_pin, !!on); |
| 76 | } |
| 77 | |
| 78 | static struct pxafb_mode_info sharp_lq43_mode = { |
| 79 | .pixclock = 101936, |
| 80 | .xres = 480, |
| 81 | .yres = 272, |
| 82 | .bpp = 32, |
| 83 | .depth = 18, |
| 84 | .hsync_len = 41, |
| 85 | .left_margin = 2, |
| 86 | .right_margin = 2, |
| 87 | .vsync_len = 10, |
| 88 | .upper_margin = 2, |
| 89 | .lower_margin = 2, |
| 90 | .sync = 0, |
| 91 | .cmap_greyscale = 0, |
| 92 | }; |
| 93 | |
| 94 | static struct pxafb_mach_info sharp_lq43_info = { |
| 95 | .modes = &sharp_lq43_mode, |
| 96 | .num_modes = 1, |
| 97 | .cmap_inverse = 0, |
| 98 | .cmap_static = 0, |
| 99 | .lcd_conn = LCD_COLOR_TFT_18BPP, |
| 100 | .pxafb_backlight_power = colibri_lcd_backlight, |
| 101 | }; |
| 102 | |
| 103 | void __init colibri_pxa3xx_init_lcd(int bl_pin) |
| 104 | { |
| 105 | lcd_bl_pin = bl_pin; |
| 106 | gpio_request(bl_pin, "lcd backlight"); |
| 107 | gpio_direction_output(bl_pin, 0); |
| 108 | set_pxa_fb_info(&sharp_lq43_info); |
| 109 | } |
| 110 | #endif |
| 111 | |
Daniel Mack | 53740df | 2009-06-17 10:32:54 +0200 | [diff] [blame] | 112 | #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE) |
| 113 | static struct mtd_partition colibri_nand_partitions[] = { |
| 114 | { |
| 115 | .name = "bootloader", |
| 116 | .offset = 0, |
| 117 | .size = SZ_512K, |
| 118 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 119 | }, |
| 120 | { |
| 121 | .name = "kernel", |
| 122 | .offset = MTDPART_OFS_APPEND, |
| 123 | .size = SZ_4M, |
| 124 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 125 | }, |
| 126 | { |
| 127 | .name = "reserved", |
| 128 | .offset = MTDPART_OFS_APPEND, |
| 129 | .size = SZ_1M, |
| 130 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 131 | }, |
| 132 | { |
| 133 | .name = "fs", |
| 134 | .offset = MTDPART_OFS_APPEND, |
| 135 | .size = MTDPART_SIZ_FULL, |
| 136 | }, |
| 137 | }; |
| 138 | |
| 139 | static struct pxa3xx_nand_platform_data colibri_nand_info = { |
| 140 | .enable_arbiter = 1, |
| 141 | .keep_config = 1, |
| 142 | .parts = colibri_nand_partitions, |
| 143 | .nr_parts = ARRAY_SIZE(colibri_nand_partitions), |
| 144 | }; |
| 145 | |
| 146 | void __init colibri_pxa3xx_init_nand(void) |
| 147 | { |
| 148 | pxa3xx_set_nand_info(&colibri_nand_info); |
| 149 | } |
| 150 | #endif |
| 151 | |