platformdata.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* linux/arch/arm/plat-samsung/platformdata.c
  2. *
  3. * Copyright 2010 Ben Dooks <ben-linux <at> fluff.org>
  4. *
  5. * Helper for platform data setting
  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 version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/slab.h>
  13. #include <linux/string.h>
  14. #include <linux/platform_device.h>
  15. #include <plat/devs.h>
  16. #include <plat/sdhci.h>
  17. void __init *s3c_set_platdata(void *pd, size_t pdsize,
  18. struct platform_device *pdev)
  19. {
  20. void *npd;
  21. if (!pd) {
  22. /* too early to use dev_name(), may not be registered */
  23. printk(KERN_ERR "%s: no platform data supplied\n", pdev->name);
  24. return NULL;
  25. }
  26. npd = kmemdup(pd, pdsize, GFP_KERNEL);
  27. if (!npd) {
  28. printk(KERN_ERR "%s: cannot clone platform data\n", pdev->name);
  29. return NULL;
  30. }
  31. pdev->dev.platform_data = npd;
  32. return npd;
  33. }
  34. void s3c_sdhci_set_platdata(struct s3c_sdhci_platdata *pd,
  35. struct s3c_sdhci_platdata *set)
  36. {
  37. set->cd_type = pd->cd_type;
  38. set->ext_cd_init = pd->ext_cd_init;
  39. set->ext_cd_cleanup = pd->ext_cd_cleanup;
  40. set->ext_cd_gpio = pd->ext_cd_gpio;
  41. set->ext_cd_gpio_invert = pd->ext_cd_gpio_invert;
  42. if (pd->max_width)
  43. set->max_width = pd->max_width;
  44. if (pd->cfg_gpio)
  45. set->cfg_gpio = pd->cfg_gpio;
  46. if (pd->host_caps)
  47. set->host_caps |= pd->host_caps;
  48. if (pd->host_caps2)
  49. set->host_caps2 |= pd->host_caps2;
  50. if (pd->pm_caps)
  51. set->pm_caps |= pd->pm_caps;
  52. }