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