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