Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Daniel Mack | acb3655 | 2009-03-23 02:04:17 +0100 | [diff] [blame] | 2 | /* |
| 3 | * arch/arm/mach-pxa/colibri-pxa3xx.c |
| 4 | * |
| 5 | * Common functions for all Toradex PXA3xx modules |
| 6 | * |
| 7 | * Daniel Mack <daniel@caiaq.de> |
Daniel Mack | acb3655 | 2009-03-23 02:04:17 +0100 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <linux/init.h> |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/platform_device.h> |
| 13 | #include <linux/gpio.h> |
Daniel Mack | 22a0200 | 2009-04-02 08:33:14 +0200 | [diff] [blame] | 14 | #include <linux/etherdevice.h> |
Daniel Mack | acb3655 | 2009-03-23 02:04:17 +0100 | [diff] [blame] | 15 | #include <asm/mach-types.h> |
| 16 | #include <mach/hardware.h> |
Masahiro Yamada | 87dfb31 | 2019-05-14 15:46:51 -0700 | [diff] [blame] | 17 | #include <linux/sizes.h> |
David Howells | 9f97da7 | 2012-03-28 18:30:01 +0100 | [diff] [blame] | 18 | #include <asm/system_info.h> |
Daniel Mack | acb3655 | 2009-03-23 02:04:17 +0100 | [diff] [blame] | 19 | #include <asm/mach/arch.h> |
| 20 | #include <asm/mach/irq.h> |
| 21 | #include <mach/pxa3xx-regs.h> |
Arnd Bergmann | 4c25c5d | 2015-01-30 10:45:33 +0100 | [diff] [blame] | 22 | #include "mfp-pxa300.h" |
| 23 | #include "colibri.h" |
Arnd Bergmann | 293b2da | 2012-08-24 15:16:48 +0200 | [diff] [blame] | 24 | #include <linux/platform_data/mmc-pxamci.h> |
| 25 | #include <linux/platform_data/video-pxafb.h> |
| 26 | #include <linux/platform_data/mtd-nand-pxa3xx.h> |
Daniel Mack | acb3655 | 2009-03-23 02:04:17 +0100 | [diff] [blame] | 27 | |
| 28 | #include "generic.h" |
| 29 | #include "devices.h" |
| 30 | |
Daniel Mack | 22a0200 | 2009-04-02 08:33:14 +0200 | [diff] [blame] | 31 | #if defined(CONFIG_AX88796) |
| 32 | #define ETHER_ADDR_LEN 6 |
| 33 | static u8 ether_mac_addr[ETHER_ADDR_LEN]; |
| 34 | |
| 35 | void __init colibri_pxa3xx_init_eth(struct ax_plat_data *plat_data) |
| 36 | { |
| 37 | int i; |
| 38 | u64 serial = ((u64) system_serial_high << 32) | system_serial_low; |
| 39 | |
| 40 | /* |
| 41 | * If the bootloader passed in a serial boot tag, which contains a |
| 42 | * valid ethernet MAC, pass it to the interface. Toradex ships the |
| 43 | * modules with their own bootloader which provides a valid MAC |
| 44 | * this way. |
| 45 | */ |
| 46 | |
| 47 | for (i = 0; i < ETHER_ADDR_LEN; i++) { |
| 48 | ether_mac_addr[i] = serial & 0xff; |
| 49 | serial >>= 8; |
| 50 | } |
| 51 | |
| 52 | if (is_valid_ether_addr(ether_mac_addr)) { |
| 53 | plat_data->flags |= AXFLG_MAC_FROMPLATFORM; |
| 54 | plat_data->mac_addr = ether_mac_addr; |
| 55 | printk(KERN_INFO "%s(): taking MAC from serial boot tag\n", |
| 56 | __func__); |
| 57 | } else { |
| 58 | plat_data->flags |= AXFLG_MAC_FROMDEV; |
| 59 | printk(KERN_INFO "%s(): no valid serial boot tag found, " |
| 60 | "taking MAC from device\n", __func__); |
| 61 | } |
| 62 | } |
| 63 | #endif |
| 64 | |
Daniel Mack | 91fcfb9 | 2009-03-23 02:04:19 +0100 | [diff] [blame] | 65 | #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE) |
| 66 | static int lcd_bl_pin; |
| 67 | |
| 68 | /* |
| 69 | * LCD panel (Sharp LQ043T3DX02) |
| 70 | */ |
| 71 | static void colibri_lcd_backlight(int on) |
| 72 | { |
| 73 | gpio_set_value(lcd_bl_pin, !!on); |
| 74 | } |
| 75 | |
| 76 | static struct pxafb_mode_info sharp_lq43_mode = { |
| 77 | .pixclock = 101936, |
| 78 | .xres = 480, |
| 79 | .yres = 272, |
| 80 | .bpp = 32, |
| 81 | .depth = 18, |
| 82 | .hsync_len = 41, |
| 83 | .left_margin = 2, |
| 84 | .right_margin = 2, |
| 85 | .vsync_len = 10, |
| 86 | .upper_margin = 2, |
| 87 | .lower_margin = 2, |
| 88 | .sync = 0, |
| 89 | .cmap_greyscale = 0, |
| 90 | }; |
| 91 | |
| 92 | static struct pxafb_mach_info sharp_lq43_info = { |
| 93 | .modes = &sharp_lq43_mode, |
| 94 | .num_modes = 1, |
| 95 | .cmap_inverse = 0, |
| 96 | .cmap_static = 0, |
| 97 | .lcd_conn = LCD_COLOR_TFT_18BPP, |
| 98 | .pxafb_backlight_power = colibri_lcd_backlight, |
| 99 | }; |
| 100 | |
| 101 | void __init colibri_pxa3xx_init_lcd(int bl_pin) |
| 102 | { |
| 103 | lcd_bl_pin = bl_pin; |
| 104 | gpio_request(bl_pin, "lcd backlight"); |
| 105 | gpio_direction_output(bl_pin, 0); |
Russell King - ARM Linux | 4321e1a | 2011-02-15 15:37:30 +0800 | [diff] [blame] | 106 | pxa_set_fb_info(NULL, &sharp_lq43_info); |
Daniel Mack | 91fcfb9 | 2009-03-23 02:04:19 +0100 | [diff] [blame] | 107 | } |
| 108 | #endif |
| 109 | |
Miquel Raynal | 349dfe6 | 2018-02-19 23:35:52 +0100 | [diff] [blame] | 110 | #if IS_ENABLED(CONFIG_MTD_NAND_MARVELL) |
Daniel Mack | 53740df | 2009-06-17 10:32:54 +0200 | [diff] [blame] | 111 | static struct mtd_partition colibri_nand_partitions[] = { |
| 112 | { |
| 113 | .name = "bootloader", |
| 114 | .offset = 0, |
| 115 | .size = SZ_512K, |
| 116 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 117 | }, |
| 118 | { |
| 119 | .name = "kernel", |
| 120 | .offset = MTDPART_OFS_APPEND, |
| 121 | .size = SZ_4M, |
| 122 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 123 | }, |
| 124 | { |
| 125 | .name = "reserved", |
| 126 | .offset = MTDPART_OFS_APPEND, |
| 127 | .size = SZ_1M, |
| 128 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 129 | }, |
| 130 | { |
| 131 | .name = "fs", |
| 132 | .offset = MTDPART_OFS_APPEND, |
| 133 | .size = MTDPART_SIZ_FULL, |
| 134 | }, |
| 135 | }; |
| 136 | |
| 137 | static struct pxa3xx_nand_platform_data colibri_nand_info = { |
Daniel Mack | 53740df | 2009-06-17 10:32:54 +0200 | [diff] [blame] | 138 | .keep_config = 1, |
Miquel Raynal | 7576594 | 2018-02-19 23:35:54 +0100 | [diff] [blame] | 139 | .parts = colibri_nand_partitions, |
| 140 | .nr_parts = ARRAY_SIZE(colibri_nand_partitions), |
Daniel Mack | 53740df | 2009-06-17 10:32:54 +0200 | [diff] [blame] | 141 | }; |
| 142 | |
| 143 | void __init colibri_pxa3xx_init_nand(void) |
| 144 | { |
| 145 | pxa3xx_set_nand_info(&colibri_nand_info); |
| 146 | } |
| 147 | #endif |
| 148 | |