colibri-pxa3xx.c 3.6 KB

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