Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *  arch/arm/mach-pxa/colibri-pxa3xx.c
0004  *
0005  *  Common functions for all Toradex PXA3xx modules
0006  *
0007  *  Daniel Mack <daniel@caiaq.de>
0008  */
0009 
0010 #include <linux/init.h>
0011 #include <linux/kernel.h>
0012 #include <linux/platform_device.h>
0013 #include <linux/gpio.h>
0014 #include <linux/etherdevice.h>
0015 #include <asm/mach-types.h>
0016 #include <linux/sizes.h>
0017 #include <asm/system_info.h>
0018 #include <asm/mach/arch.h>
0019 #include <asm/mach/irq.h>
0020 #include "pxa3xx-regs.h"
0021 #include "mfp-pxa300.h"
0022 #include "colibri.h"
0023 #include <linux/platform_data/mmc-pxamci.h>
0024 #include <linux/platform_data/video-pxafb.h>
0025 #include <linux/platform_data/mtd-nand-pxa3xx.h>
0026 
0027 #include "generic.h"
0028 #include "devices.h"
0029 
0030 #if defined(CONFIG_AX88796)
0031 #define ETHER_ADDR_LEN 6
0032 static u8 ether_mac_addr[ETHER_ADDR_LEN];
0033 
0034 void __init colibri_pxa3xx_init_eth(struct ax_plat_data *plat_data)
0035 {
0036     int i;
0037     u64 serial = ((u64) system_serial_high << 32) | system_serial_low;
0038 
0039     /*
0040      * If the bootloader passed in a serial boot tag, which contains a
0041      * valid ethernet MAC, pass it to the interface. Toradex ships the
0042      * modules with their own bootloader which provides a valid MAC
0043      * this way.
0044      */
0045 
0046     for (i = 0; i < ETHER_ADDR_LEN; i++) {
0047         ether_mac_addr[i] = serial & 0xff;
0048         serial >>= 8;
0049     }
0050 
0051     if (is_valid_ether_addr(ether_mac_addr)) {
0052         plat_data->flags |= AXFLG_MAC_FROMPLATFORM;
0053         plat_data->mac_addr = ether_mac_addr;
0054         printk(KERN_INFO "%s(): taking MAC from serial boot tag\n",
0055             __func__);
0056     } else {
0057         plat_data->flags |= AXFLG_MAC_FROMDEV;
0058         printk(KERN_INFO "%s(): no valid serial boot tag found, "
0059             "taking MAC from device\n", __func__);
0060     }
0061 }
0062 #endif
0063 
0064 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
0065 static int lcd_bl_pin;
0066 
0067 /*
0068  * LCD panel (Sharp LQ043T3DX02)
0069  */
0070 static void colibri_lcd_backlight(int on)
0071 {
0072     gpio_set_value(lcd_bl_pin, !!on);
0073 }
0074 
0075 static struct pxafb_mode_info sharp_lq43_mode = {
0076     .pixclock   = 101936,
0077     .xres       = 480,
0078     .yres       = 272,
0079     .bpp        = 32,
0080     .depth      = 18,
0081     .hsync_len      = 41,
0082     .left_margin    = 2,
0083     .right_margin   = 2,
0084     .vsync_len      = 10,
0085     .upper_margin   = 2,
0086     .lower_margin   = 2,
0087     .sync       = 0,
0088     .cmap_greyscale = 0,
0089 };
0090 
0091 static struct pxafb_mach_info sharp_lq43_info = {
0092     .modes      = &sharp_lq43_mode,
0093     .num_modes  = 1,
0094     .cmap_inverse   = 0,
0095     .cmap_static    = 0,
0096     .lcd_conn   = LCD_COLOR_TFT_18BPP,
0097     .pxafb_backlight_power = colibri_lcd_backlight,
0098 };
0099 
0100 void __init colibri_pxa3xx_init_lcd(int bl_pin)
0101 {
0102     lcd_bl_pin = bl_pin;
0103     gpio_request(bl_pin, "lcd backlight");
0104     gpio_direction_output(bl_pin, 0);
0105     pxa_set_fb_info(NULL, &sharp_lq43_info);
0106 }
0107 #endif
0108 
0109 #if IS_ENABLED(CONFIG_MTD_NAND_MARVELL)
0110 static struct mtd_partition colibri_nand_partitions[] = {
0111     {
0112         .name        = "bootloader",
0113         .offset      = 0,
0114         .size        = SZ_512K,
0115         .mask_flags  = MTD_WRITEABLE, /* force read-only */
0116     },
0117     {
0118         .name        = "kernel",
0119         .offset      = MTDPART_OFS_APPEND,
0120         .size        = SZ_4M,
0121         .mask_flags  = MTD_WRITEABLE, /* force read-only */
0122     },
0123     {
0124         .name        = "reserved",
0125         .offset      = MTDPART_OFS_APPEND,
0126         .size        = SZ_1M,
0127         .mask_flags  = MTD_WRITEABLE, /* force read-only */
0128     },
0129     {
0130         .name        = "fs",
0131         .offset      = MTDPART_OFS_APPEND,
0132         .size        = MTDPART_SIZ_FULL,
0133     },
0134 };
0135 
0136 static struct pxa3xx_nand_platform_data colibri_nand_info = {
0137     .keep_config    = 1,
0138     .parts      = colibri_nand_partitions,
0139     .nr_parts   = ARRAY_SIZE(colibri_nand_partitions),
0140 };
0141 
0142 void __init colibri_pxa3xx_init_nand(void)
0143 {
0144     pxa3xx_set_nand_info(&colibri_nand_info);
0145 }
0146 #endif
0147