asic_devices.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779
  1. /*
  2. * ASIC Device List Intialization
  3. *
  4. * Description: Defines the platform resources for the SA settop.
  5. *
  6. * Copyright (C) 2005-2009 Scientific-Atlanta, Inc.
  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 as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. *
  22. * Author: Ken Eppinett
  23. * David Schleef <ds@schleef.org>
  24. *
  25. * Description: Defines the platform resources for the SA settop.
  26. *
  27. * NOTE: The bootloader allocates persistent memory at an address which is
  28. * 16 MiB below the end of the highest address in KSEG0. All fixed
  29. * address memory reservations must avoid this region.
  30. */
  31. #include <linux/device.h>
  32. #include <linux/kernel.h>
  33. #include <linux/init.h>
  34. #include <linux/resource.h>
  35. #include <linux/serial_reg.h>
  36. #include <linux/io.h>
  37. #include <linux/bootmem.h>
  38. #include <linux/mm.h>
  39. #include <linux/platform_device.h>
  40. #include <linux/module.h>
  41. #include <asm/page.h>
  42. #include <linux/swap.h>
  43. #include <linux/highmem.h>
  44. #include <linux/dma-mapping.h>
  45. #include <asm/mach-powertv/asic.h>
  46. #include <asm/mach-powertv/asic_regs.h>
  47. #include <asm/mach-powertv/interrupts.h>
  48. #ifdef CONFIG_BOOTLOADER_DRIVER
  49. #include <asm/mach-powertv/kbldr.h>
  50. #endif
  51. #include <asm/bootinfo.h>
  52. #define BOOTLDRFAMILY(byte1, byte0) (((byte1) << 8) | (byte0))
  53. /*
  54. * Forward Prototypes
  55. */
  56. static void pmem_setup_resource(void);
  57. /*
  58. * Global Variables
  59. */
  60. enum asic_type asic;
  61. unsigned int platform_features;
  62. unsigned int platform_family;
  63. struct register_map _asic_register_map;
  64. EXPORT_SYMBOL(_asic_register_map); /* Exported for testing */
  65. unsigned long asic_phy_base;
  66. unsigned long asic_base;
  67. EXPORT_SYMBOL(asic_base); /* Exported for testing */
  68. struct resource *gp_resources;
  69. static bool usb_configured;
  70. /*
  71. * Don't recommend to use it directly, it is usually used by kernel internally.
  72. * Portable code should be using interfaces such as ioremp, dma_map_single, etc.
  73. */
  74. unsigned long phys_to_bus_offset;
  75. EXPORT_SYMBOL(phys_to_bus_offset);
  76. /*
  77. *
  78. * IO Resource Definition
  79. *
  80. */
  81. struct resource asic_resource = {
  82. .name = "ASIC Resource",
  83. .start = 0,
  84. .end = ASIC_IO_SIZE,
  85. .flags = IORESOURCE_MEM,
  86. };
  87. /*
  88. *
  89. * USB Host Resource Definition
  90. *
  91. */
  92. static struct resource ehci_resources[] = {
  93. {
  94. .parent = &asic_resource,
  95. .start = 0,
  96. .end = 0xff,
  97. .flags = IORESOURCE_MEM,
  98. },
  99. {
  100. .start = irq_usbehci,
  101. .end = irq_usbehci,
  102. .flags = IORESOURCE_IRQ,
  103. },
  104. };
  105. static u64 ehci_dmamask = DMA_BIT_MASK(32);
  106. static struct platform_device ehci_device = {
  107. .name = "powertv-ehci",
  108. .id = 0,
  109. .num_resources = 2,
  110. .resource = ehci_resources,
  111. .dev = {
  112. .dma_mask = &ehci_dmamask,
  113. .coherent_dma_mask = DMA_BIT_MASK(32),
  114. },
  115. };
  116. static struct resource ohci_resources[] = {
  117. {
  118. .parent = &asic_resource,
  119. .start = 0,
  120. .end = 0xff,
  121. .flags = IORESOURCE_MEM,
  122. },
  123. {
  124. .start = irq_usbohci,
  125. .end = irq_usbohci,
  126. .flags = IORESOURCE_IRQ,
  127. },
  128. };
  129. static u64 ohci_dmamask = DMA_BIT_MASK(32);
  130. static struct platform_device ohci_device = {
  131. .name = "powertv-ohci",
  132. .id = 0,
  133. .num_resources = 2,
  134. .resource = ohci_resources,
  135. .dev = {
  136. .dma_mask = &ohci_dmamask,
  137. .coherent_dma_mask = DMA_BIT_MASK(32),
  138. },
  139. };
  140. static struct platform_device *platform_devices[] = {
  141. &ehci_device,
  142. &ohci_device,
  143. };
  144. /*
  145. *
  146. * Platform Configuration and Device Initialization
  147. *
  148. */
  149. static void __init fs_update(int pe, int md, int sdiv, int disable_div_by_3)
  150. {
  151. int en_prg, byp, pwr, nsb, val;
  152. int sout;
  153. sout = 1;
  154. en_prg = 1;
  155. byp = 0;
  156. nsb = 1;
  157. pwr = 1;
  158. val = ((sdiv << 29) | (md << 24) | (pe<<8) | (sout<<3) | (byp<<2) |
  159. (nsb<<1) | (disable_div_by_3<<5));
  160. asic_write(val, usb_fs);
  161. asic_write(val | (en_prg<<4), usb_fs);
  162. asic_write(val | (en_prg<<4) | pwr, usb_fs);
  163. }
  164. /*
  165. * Allow override of bootloader-specified model
  166. */
  167. static char __initdata cmdline[COMMAND_LINE_SIZE];
  168. #define FORCEFAMILY_PARAM "forcefamily"
  169. static __init int check_forcefamily(unsigned char forced_family[2])
  170. {
  171. const char *p;
  172. forced_family[0] = '\0';
  173. forced_family[1] = '\0';
  174. /* Check the command line for a forcefamily directive */
  175. strncpy(cmdline, arcs_cmdline, COMMAND_LINE_SIZE - 1);
  176. p = strstr(cmdline, FORCEFAMILY_PARAM);
  177. if (p && (p != cmdline) && (*(p - 1) != ' '))
  178. p = strstr(p, " " FORCEFAMILY_PARAM "=");
  179. if (p) {
  180. p += strlen(FORCEFAMILY_PARAM "=");
  181. if (*p == '\0' || *(p + 1) == '\0' ||
  182. (*(p + 2) != '\0' && *(p + 2) != ' '))
  183. pr_err(FORCEFAMILY_PARAM " must be exactly two "
  184. "characters long, ignoring value\n");
  185. else {
  186. forced_family[0] = *p;
  187. forced_family[1] = *(p + 1);
  188. }
  189. }
  190. return 0;
  191. }
  192. /*
  193. * platform_set_family - determine major platform family type.
  194. *
  195. * Returns family type; -1 if none
  196. * Returns the family type; -1 if none
  197. *
  198. */
  199. static __init noinline void platform_set_family(void)
  200. {
  201. #define BOOTLDRFAMILY(byte1, byte0) (((byte1) << 8) | (byte0))
  202. unsigned char forced_family[2];
  203. unsigned short bootldr_family;
  204. check_forcefamily(forced_family);
  205. if (forced_family[0] != '\0' && forced_family[1] != '\0')
  206. bootldr_family = BOOTLDRFAMILY(forced_family[0],
  207. forced_family[1]);
  208. else {
  209. #ifdef CONFIG_BOOTLOADER_DRIVER
  210. bootldr_family = (unsigned short) kbldr_GetSWFamily();
  211. #else
  212. #if defined(CONFIG_BOOTLOADER_FAMILY)
  213. bootldr_family = (unsigned short) BOOTLDRFAMILY(
  214. CONFIG_BOOTLOADER_FAMILY[0],
  215. CONFIG_BOOTLOADER_FAMILY[1]);
  216. #else
  217. #error "Unknown Bootloader Family"
  218. #endif
  219. #endif
  220. }
  221. pr_info("Bootloader Family = 0x%04X\n", bootldr_family);
  222. switch (bootldr_family) {
  223. case BOOTLDRFAMILY('R', '1'):
  224. platform_family = FAMILY_1500;
  225. break;
  226. case BOOTLDRFAMILY('4', '4'):
  227. platform_family = FAMILY_4500;
  228. break;
  229. case BOOTLDRFAMILY('4', '6'):
  230. platform_family = FAMILY_4600;
  231. break;
  232. case BOOTLDRFAMILY('A', '1'):
  233. platform_family = FAMILY_4600VZA;
  234. break;
  235. case BOOTLDRFAMILY('8', '5'):
  236. platform_family = FAMILY_8500;
  237. break;
  238. case BOOTLDRFAMILY('R', '2'):
  239. platform_family = FAMILY_8500RNG;
  240. break;
  241. case BOOTLDRFAMILY('8', '6'):
  242. platform_family = FAMILY_8600;
  243. break;
  244. case BOOTLDRFAMILY('B', '1'):
  245. platform_family = FAMILY_8600VZB;
  246. break;
  247. case BOOTLDRFAMILY('E', '1'):
  248. platform_family = FAMILY_1500VZE;
  249. break;
  250. case BOOTLDRFAMILY('F', '1'):
  251. platform_family = FAMILY_1500VZF;
  252. break;
  253. default:
  254. platform_family = -1;
  255. }
  256. }
  257. unsigned int platform_get_family(void)
  258. {
  259. return platform_family;
  260. }
  261. EXPORT_SYMBOL(platform_get_family);
  262. /*
  263. * \brief usb_eye_configure() for optimizing the USB eye on Calliope.
  264. *
  265. * \param unsigned int value saved to the register.
  266. *
  267. * \return none
  268. *
  269. */
  270. static void __init usb_eye_configure(unsigned int value)
  271. {
  272. asic_write(asic_read(crt_spare) | value, crt_spare);
  273. }
  274. /*
  275. * platform_get_asic - determine the ASIC type.
  276. *
  277. * \param none
  278. *
  279. * \return ASIC type; ASIC_UNKNOWN if none
  280. *
  281. */
  282. enum asic_type platform_get_asic(void)
  283. {
  284. return asic;
  285. }
  286. EXPORT_SYMBOL(platform_get_asic);
  287. /*
  288. * platform_configure_usb - usb configuration based on platform type.
  289. * @bcm1_usb2_ctl: value for the BCM1_USB2_CTL register, which is
  290. * quirky
  291. */
  292. static void __init platform_configure_usb(void)
  293. {
  294. u32 bcm1_usb2_ctl;
  295. if (usb_configured)
  296. return;
  297. switch (asic) {
  298. case ASIC_ZEUS:
  299. fs_update(0x0000, 0x11, 0x02, 0);
  300. bcm1_usb2_ctl = 0x803;
  301. break;
  302. case ASIC_CRONUS:
  303. case ASIC_CRONUSLITE:
  304. fs_update(0x0000, 0x11, 0x02, 0);
  305. bcm1_usb2_ctl = 0x803;
  306. break;
  307. case ASIC_CALLIOPE:
  308. fs_update(0x0000, 0x11, 0x02, 1);
  309. switch (platform_family) {
  310. case FAMILY_1500VZE:
  311. break;
  312. case FAMILY_1500VZF:
  313. usb_eye_configure(0x003c0000);
  314. break;
  315. default:
  316. usb_eye_configure(0x00300000);
  317. break;
  318. }
  319. bcm1_usb2_ctl = 0x803;
  320. break;
  321. default:
  322. pr_err("Unknown ASIC type: %d\n", asic);
  323. break;
  324. }
  325. /* turn on USB power */
  326. asic_write(0, usb2_strap);
  327. /* Enable all OHCI interrupts */
  328. asic_write(bcm1_usb2_ctl, usb2_control);
  329. /* USB2_STBUS_OBC store32/load32 */
  330. asic_write(3, usb2_stbus_obc);
  331. /* USB2_STBUS_MESS_SIZE 2 packets */
  332. asic_write(1, usb2_stbus_mess_size);
  333. /* USB2_STBUS_CHUNK_SIZE 2 packets */
  334. asic_write(1, usb2_stbus_chunk_size);
  335. usb_configured = true;
  336. }
  337. /*
  338. * Set up the USB EHCI interface
  339. */
  340. void platform_configure_usb_ehci()
  341. {
  342. platform_configure_usb();
  343. }
  344. /*
  345. * Set up the USB OHCI interface
  346. */
  347. void platform_configure_usb_ohci()
  348. {
  349. platform_configure_usb();
  350. }
  351. /*
  352. * Shut the USB EHCI interface down--currently a NOP
  353. */
  354. void platform_unconfigure_usb_ehci()
  355. {
  356. }
  357. /*
  358. * Shut the USB OHCI interface down--currently a NOP
  359. */
  360. void platform_unconfigure_usb_ohci()
  361. {
  362. }
  363. static void __init set_register_map(unsigned long phys_base,
  364. const struct register_map *map)
  365. {
  366. asic_phy_base = phys_base;
  367. _asic_register_map = *map;
  368. register_map_virtualize(&_asic_register_map);
  369. asic_base = (unsigned long)ioremap_nocache(phys_base, ASIC_IO_SIZE);
  370. }
  371. /**
  372. * configure_platform - configuration based on platform type.
  373. */
  374. void __init configure_platform(void)
  375. {
  376. platform_set_family();
  377. switch (platform_family) {
  378. case FAMILY_1500:
  379. case FAMILY_1500VZE:
  380. case FAMILY_1500VZF:
  381. platform_features = FFS_CAPABLE;
  382. asic = ASIC_CALLIOPE;
  383. set_register_map(CALLIOPE_IO_BASE, &calliope_register_map);
  384. if (platform_family == FAMILY_1500VZE) {
  385. gp_resources = non_dvr_vze_calliope_resources;
  386. pr_info("Platform: 1500/Vz Class E - "
  387. "CALLIOPE, NON_DVR_CAPABLE\n");
  388. } else if (platform_family == FAMILY_1500VZF) {
  389. gp_resources = non_dvr_vzf_calliope_resources;
  390. pr_info("Platform: 1500/Vz Class F - "
  391. "CALLIOPE, NON_DVR_CAPABLE\n");
  392. } else {
  393. gp_resources = non_dvr_calliope_resources;
  394. pr_info("Platform: 1500/RNG100 - CALLIOPE, "
  395. "NON_DVR_CAPABLE\n");
  396. }
  397. break;
  398. case FAMILY_4500:
  399. platform_features = FFS_CAPABLE | PCIE_CAPABLE |
  400. DISPLAY_CAPABLE;
  401. asic = ASIC_ZEUS;
  402. set_register_map(ZEUS_IO_BASE, &zeus_register_map);
  403. gp_resources = non_dvr_zeus_resources;
  404. pr_info("Platform: 4500 - ZEUS, NON_DVR_CAPABLE\n");
  405. break;
  406. case FAMILY_4600:
  407. {
  408. unsigned int chipversion = 0;
  409. /* The settop has PCIE but it isn't used, so don't advertise
  410. * it*/
  411. platform_features = FFS_CAPABLE | DISPLAY_CAPABLE;
  412. /* ASIC version will determine if this is a real CronusLite or
  413. * Castrati(Cronus) */
  414. chipversion = asic_read(chipver3) << 24;
  415. chipversion |= asic_read(chipver2) << 16;
  416. chipversion |= asic_read(chipver1) << 8;
  417. chipversion |= asic_read(chipver0);
  418. if ((chipversion == CRONUS_10) || (chipversion == CRONUS_11))
  419. asic = ASIC_CRONUS;
  420. else
  421. asic = ASIC_CRONUSLITE;
  422. /* Cronus and Cronus Lite have the same register map */
  423. set_register_map(CRONUS_IO_BASE, &cronus_register_map);
  424. gp_resources = non_dvr_cronuslite_resources;
  425. pr_info("Platform: 4600 - %s, NON_DVR_CAPABLE, "
  426. "chipversion=0x%08X\n",
  427. (asic == ASIC_CRONUS) ? "CRONUS" : "CRONUS LITE",
  428. chipversion);
  429. break;
  430. }
  431. case FAMILY_4600VZA:
  432. platform_features = FFS_CAPABLE | DISPLAY_CAPABLE;
  433. asic = ASIC_CRONUS;
  434. set_register_map(CRONUS_IO_BASE, &cronus_register_map);
  435. gp_resources = non_dvr_cronus_resources;
  436. pr_info("Platform: Vz Class A - CRONUS, NON_DVR_CAPABLE\n");
  437. break;
  438. case FAMILY_8500:
  439. case FAMILY_8500RNG:
  440. platform_features = DVR_CAPABLE | PCIE_CAPABLE |
  441. DISPLAY_CAPABLE;
  442. asic = ASIC_ZEUS;
  443. set_register_map(ZEUS_IO_BASE, &zeus_register_map);
  444. gp_resources = dvr_zeus_resources;
  445. pr_info("Platform: 8500/RNG200 - ZEUS, DVR_CAPABLE\n");
  446. break;
  447. case FAMILY_8600:
  448. case FAMILY_8600VZB:
  449. platform_features = DVR_CAPABLE | PCIE_CAPABLE |
  450. DISPLAY_CAPABLE;
  451. asic = ASIC_CRONUS;
  452. set_register_map(CRONUS_IO_BASE, &cronus_register_map);
  453. gp_resources = dvr_cronus_resources;
  454. pr_info("Platform: 8600/Vz Class B - CRONUS, "
  455. "DVR_CAPABLE\n");
  456. break;
  457. default:
  458. pr_crit("Platform: UNKNOWN PLATFORM\n");
  459. break;
  460. }
  461. switch (asic) {
  462. case ASIC_ZEUS:
  463. phys_to_bus_offset = 0x30000000;
  464. break;
  465. case ASIC_CALLIOPE:
  466. phys_to_bus_offset = 0x10000000;
  467. break;
  468. case ASIC_CRONUSLITE:
  469. /* Fall through */
  470. case ASIC_CRONUS:
  471. /*
  472. * TODO: We suppose 0x10000000 aliases into 0x20000000-
  473. * 0x2XXXXXXX. If 0x10000000 aliases into 0x60000000-
  474. * 0x6XXXXXXX, the offset should be 0x50000000, not 0x10000000.
  475. */
  476. phys_to_bus_offset = 0x10000000;
  477. break;
  478. default:
  479. phys_to_bus_offset = 0x00000000;
  480. break;
  481. }
  482. }
  483. /**
  484. * platform_devices_init - sets up USB device resourse.
  485. */
  486. static int __init platform_devices_init(void)
  487. {
  488. pr_notice("%s: ----- Initializing USB resources -----\n", __func__);
  489. asic_resource.start = asic_phy_base;
  490. asic_resource.end += asic_resource.start;
  491. ehci_resources[0].start = asic_reg_phys_addr(ehci_hcapbase);
  492. ehci_resources[0].end += ehci_resources[0].start;
  493. ohci_resources[0].start = asic_reg_phys_addr(ohci_hc_revision);
  494. ohci_resources[0].end += ohci_resources[0].start;
  495. set_io_port_base(0);
  496. platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
  497. return 0;
  498. }
  499. arch_initcall(platform_devices_init);
  500. /*
  501. *
  502. * BOOTMEM ALLOCATION
  503. *
  504. */
  505. /*
  506. * Allocates/reserves the Platform memory resources early in the boot process.
  507. * This ignores any resources that are designated IORESOURCE_IO
  508. */
  509. void __init platform_alloc_bootmem(void)
  510. {
  511. int i;
  512. int total = 0;
  513. /* Get persistent memory data from command line before allocating
  514. * resources. This need to happen before normal command line parsing
  515. * has been done */
  516. pmem_setup_resource();
  517. /* Loop through looking for resources that want a particular address */
  518. for (i = 0; gp_resources[i].flags != 0; i++) {
  519. int size = gp_resources[i].end - gp_resources[i].start + 1;
  520. if ((gp_resources[i].start != 0) &&
  521. ((gp_resources[i].flags & IORESOURCE_MEM) != 0)) {
  522. reserve_bootmem(bus_to_phys(gp_resources[i].start),
  523. size, 0);
  524. total += gp_resources[i].end -
  525. gp_resources[i].start + 1;
  526. pr_info("reserve resource %s at %08x (%u bytes)\n",
  527. gp_resources[i].name, gp_resources[i].start,
  528. gp_resources[i].end -
  529. gp_resources[i].start + 1);
  530. }
  531. }
  532. /* Loop through assigning addresses for those that are left */
  533. for (i = 0; gp_resources[i].flags != 0; i++) {
  534. int size = gp_resources[i].end - gp_resources[i].start + 1;
  535. if ((gp_resources[i].start == 0) &&
  536. ((gp_resources[i].flags & IORESOURCE_MEM) != 0)) {
  537. void *mem = alloc_bootmem_pages(size);
  538. if (mem == NULL)
  539. pr_err("Unable to allocate bootmem pages "
  540. "for %s\n", gp_resources[i].name);
  541. else {
  542. gp_resources[i].start =
  543. phys_to_bus(virt_to_phys(mem));
  544. gp_resources[i].end =
  545. gp_resources[i].start + size - 1;
  546. total += size;
  547. pr_info("allocate resource %s at %08x "
  548. "(%u bytes)\n",
  549. gp_resources[i].name,
  550. gp_resources[i].start, size);
  551. }
  552. }
  553. }
  554. pr_info("Total Platform driver memory allocation: 0x%08x\n", total);
  555. /* indicate resources that are platform I/O related */
  556. for (i = 0; gp_resources[i].flags != 0; i++) {
  557. if ((gp_resources[i].start != 0) &&
  558. ((gp_resources[i].flags & IORESOURCE_IO) != 0)) {
  559. pr_info("reserved platform resource %s at %08x\n",
  560. gp_resources[i].name, gp_resources[i].start);
  561. }
  562. }
  563. }
  564. /*
  565. *
  566. * PERSISTENT MEMORY (PMEM) CONFIGURATION
  567. *
  568. */
  569. static unsigned long pmemaddr __initdata;
  570. static int __init early_param_pmemaddr(char *p)
  571. {
  572. pmemaddr = (unsigned long)simple_strtoul(p, NULL, 0);
  573. return 0;
  574. }
  575. early_param("pmemaddr", early_param_pmemaddr);
  576. static long pmemlen __initdata;
  577. static int __init early_param_pmemlen(char *p)
  578. {
  579. /* TODO: we can use this code when and if the bootloader ever changes this */
  580. #if 0
  581. pmemlen = (unsigned long)simple_strtoul(p, NULL, 0);
  582. #else
  583. pmemlen = 0x20000;
  584. #endif
  585. return 0;
  586. }
  587. early_param("pmemlen", early_param_pmemlen);
  588. /*
  589. * Set up persistent memory. If we were given values, we patch the array of
  590. * resources. Otherwise, persistent memory may be allocated anywhere at all.
  591. */
  592. static void __init pmem_setup_resource(void)
  593. {
  594. struct resource *resource;
  595. resource = asic_resource_get("DiagPersistentMemory");
  596. if (resource && pmemaddr && pmemlen) {
  597. /* The address provided by bootloader is in kseg0. Convert to
  598. * a bus address. */
  599. resource->start = phys_to_bus(pmemaddr - 0x80000000);
  600. resource->end = resource->start + pmemlen - 1;
  601. pr_info("persistent memory: start=0x%x end=0x%x\n",
  602. resource->start, resource->end);
  603. }
  604. }
  605. /*
  606. *
  607. * RESOURCE ACCESS FUNCTIONS
  608. *
  609. */
  610. /**
  611. * asic_resource_get - retrieves parameters for a platform resource.
  612. * @name: string to match resource
  613. *
  614. * Returns a pointer to a struct resource corresponding to the given name.
  615. *
  616. * CANNOT BE NAMED platform_resource_get, which would be the obvious choice,
  617. * as this function name is already declared
  618. */
  619. struct resource *asic_resource_get(const char *name)
  620. {
  621. int i;
  622. for (i = 0; gp_resources[i].flags != 0; i++) {
  623. if (strcmp(gp_resources[i].name, name) == 0)
  624. return &gp_resources[i];
  625. }
  626. return NULL;
  627. }
  628. EXPORT_SYMBOL(asic_resource_get);
  629. /**
  630. * platform_release_memory - release pre-allocated memory
  631. * @ptr: pointer to memory to release
  632. * @size: size of resource
  633. *
  634. * This must only be called for memory allocated or reserved via the boot
  635. * memory allocator.
  636. */
  637. void platform_release_memory(void *ptr, int size)
  638. {
  639. unsigned long addr;
  640. unsigned long end;
  641. addr = ((unsigned long)ptr + (PAGE_SIZE - 1)) & PAGE_MASK;
  642. end = ((unsigned long)ptr + size) & PAGE_MASK;
  643. for (; addr < end; addr += PAGE_SIZE) {
  644. ClearPageReserved(virt_to_page(__va(addr)));
  645. init_page_count(virt_to_page(__va(addr)));
  646. free_page((unsigned long)__va(addr));
  647. }
  648. }
  649. EXPORT_SYMBOL(platform_release_memory);
  650. /*
  651. *
  652. * FEATURE AVAILABILITY FUNCTIONS
  653. *
  654. */
  655. int platform_supports_dvr(void)
  656. {
  657. return (platform_features & DVR_CAPABLE) != 0;
  658. }
  659. int platform_supports_ffs(void)
  660. {
  661. return (platform_features & FFS_CAPABLE) != 0;
  662. }
  663. int platform_supports_pcie(void)
  664. {
  665. return (platform_features & PCIE_CAPABLE) != 0;
  666. }
  667. int platform_supports_display(void)
  668. {
  669. return (platform_features & DISPLAY_CAPABLE) != 0;
  670. }