asic_regs.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright (C) 2009 Cisco Systems, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef __ASM_MACH_POWERTV_ASIC_H_
  19. #define __ASM_MACH_POWERTV_ASIC_H_
  20. #include <linux/io.h>
  21. /* ASIC types */
  22. enum asic_type {
  23. ASIC_UNKNOWN,
  24. ASIC_ZEUS,
  25. ASIC_CALLIOPE,
  26. ASIC_CRONUS,
  27. ASIC_CRONUSLITE,
  28. ASIC_GAIA,
  29. ASICS /* Number of supported ASICs */
  30. };
  31. /* hardcoded values read from Chip Version registers */
  32. #define CRONUS_10 0x0B4C1C20
  33. #define CRONUS_11 0x0B4C1C21
  34. #define CRONUSLITE_10 0x0B4C1C40
  35. #define NAND_FLASH_BASE 0x03000000
  36. #define CALLIOPE_IO_BASE 0x08000000
  37. #define GAIA_IO_BASE 0x09000000
  38. #define CRONUS_IO_BASE 0x09000000
  39. #define ZEUS_IO_BASE 0x09000000
  40. #define ASIC_IO_SIZE 0x01000000
  41. /* Definitions for backward compatibility */
  42. #define UART1_INTSTAT uart1_intstat
  43. #define UART1_INTEN uart1_inten
  44. #define UART1_CONFIG1 uart1_config1
  45. #define UART1_CONFIG2 uart1_config2
  46. #define UART1_DIVISORHI uart1_divisorhi
  47. #define UART1_DIVISORLO uart1_divisorlo
  48. #define UART1_DATA uart1_data
  49. #define UART1_STATUS uart1_status
  50. /* ASIC register enumeration */
  51. union register_map_entry {
  52. unsigned long phys;
  53. u32 *virt;
  54. };
  55. #define REGISTER_MAP_ELEMENT(x) union register_map_entry x;
  56. struct register_map {
  57. #include <asm/mach-powertv/asic_reg_map.h>
  58. };
  59. #undef REGISTER_MAP_ELEMENT
  60. /**
  61. * register_map_offset_phys - add an offset to the physical address
  62. * @map: Pointer to the &struct register_map
  63. * @offset: Value to add
  64. *
  65. * Only adds the base to non-zero physical addresses
  66. */
  67. static inline void register_map_offset_phys(struct register_map *map,
  68. unsigned long offset)
  69. {
  70. #define REGISTER_MAP_ELEMENT(x) do { \
  71. if (map->x.phys != 0) \
  72. map->x.phys += offset; \
  73. } while (false);
  74. #include <asm/mach-powertv/asic_reg_map.h>
  75. #undef REGISTER_MAP_ELEMENT
  76. }
  77. /**
  78. * register_map_virtualize - Convert &register_map to virtual addresses
  79. * @map: Pointer to &register_map to virtualize
  80. */
  81. static inline void register_map_virtualize(struct register_map *map)
  82. {
  83. #define REGISTER_MAP_ELEMENT(x) do { \
  84. map->x.virt = (!map->x.phys) ? NULL : \
  85. UNCAC_ADDR(phys_to_virt(map->x.phys)); \
  86. } while (false);
  87. #include <asm/mach-powertv/asic_reg_map.h>
  88. #undef REGISTER_MAP_ELEMENT
  89. }
  90. extern struct register_map _asic_register_map;
  91. extern unsigned long asic_phy_base;
  92. /*
  93. * Macros to interface to registers through their ioremapped address
  94. * asic_reg_phys_addr Returns the physical address of the given register
  95. * asic_reg_addr Returns the iomapped virtual address of the given
  96. * register.
  97. */
  98. #define asic_reg_addr(x) (_asic_register_map.x.virt)
  99. #define asic_reg_phys_addr(x) (virt_to_phys((void *) CAC_ADDR( \
  100. (unsigned long) asic_reg_addr(x))))
  101. /*
  102. * The asic_reg macro is gone. It should be replaced by either asic_read or
  103. * asic_write, as appropriate.
  104. */
  105. #define asic_read(x) readl(asic_reg_addr(x))
  106. #define asic_write(v, x) writel(v, asic_reg_addr(x))
  107. extern void asic_irq_init(void);
  108. #endif