common.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Code commons to all DaVinci SoCs.
  3. *
  4. * Author: Mark A. Greer <mgreer@mvista.com>
  5. *
  6. * 2009 (c) MontaVista Software, Inc. This file is licensed under
  7. * the terms of the GNU General Public License version 2. This program
  8. * is licensed "as is" without any warranty of any kind, whether express
  9. * or implied.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/io.h>
  13. #include <asm/tlb.h>
  14. #include <asm/mach/map.h>
  15. #include <mach/common.h>
  16. #include <mach/cputype.h>
  17. #include "clock.h"
  18. struct davinci_soc_info davinci_soc_info;
  19. EXPORT_SYMBOL(davinci_soc_info);
  20. static struct davinci_id * __init davinci_get_id(u32 jtag_id)
  21. {
  22. int i;
  23. struct davinci_id *dip;
  24. u8 variant = (jtag_id & 0xf0000000) >> 28;
  25. u16 part_no = (jtag_id & 0x0ffff000) >> 12;
  26. for (i = 0, dip = davinci_soc_info.ids; i < davinci_soc_info.ids_num;
  27. i++, dip++)
  28. /* Don't care about the manufacturer right now */
  29. if ((dip->part_no == part_no) && (dip->variant == variant))
  30. return dip;
  31. return NULL;
  32. }
  33. void __init davinci_common_init(struct davinci_soc_info *soc_info)
  34. {
  35. int ret;
  36. struct davinci_id *dip;
  37. if (!soc_info) {
  38. ret = -EINVAL;
  39. goto err;
  40. }
  41. memcpy(&davinci_soc_info, soc_info, sizeof(struct davinci_soc_info));
  42. if (davinci_soc_info.io_desc && (davinci_soc_info.io_desc_num > 0))
  43. iotable_init(davinci_soc_info.io_desc,
  44. davinci_soc_info.io_desc_num);
  45. /*
  46. * Normally devicemaps_init() would flush caches and tlb after
  47. * mdesc->map_io(), but we must also do it here because of the CPU
  48. * revision check below.
  49. */
  50. local_flush_tlb_all();
  51. flush_cache_all();
  52. /*
  53. * We want to check CPU revision early for cpu_is_xxxx() macros.
  54. * IO space mapping must be initialized before we can do that.
  55. */
  56. davinci_soc_info.jtag_id = __raw_readl(davinci_soc_info.jtag_id_base);
  57. dip = davinci_get_id(davinci_soc_info.jtag_id);
  58. if (!dip) {
  59. ret = -EINVAL;
  60. goto err;
  61. }
  62. davinci_soc_info.cpu_id = dip->cpu_id;
  63. pr_info("DaVinci %s variant 0x%x\n", dip->name, dip->variant);
  64. if (davinci_soc_info.cpu_clks) {
  65. ret = davinci_clk_init(davinci_soc_info.cpu_clks);
  66. if (ret != 0)
  67. goto err;
  68. }
  69. return;
  70. err:
  71. pr_err("davinci_common_init: SoC Initialization failed\n");
  72. }