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