colibri-pxa3xx.c 3.4 KB

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