platformdata.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright 2010 Ben Dooks <ben-linux <at> fluff.org>
  4. //
  5. // Helper for platform data setting
  6. #include <linux/kernel.h>
  7. #include <linux/slab.h>
  8. #include <linux/string.h>
  9. #include <linux/platform_device.h>
  10. #include <plat/devs.h>
  11. #include <plat/sdhci.h>
  12. void __init *s3c_set_platdata(void *pd, size_t pdsize,
  13. struct platform_device *pdev)
  14. {
  15. void *npd;
  16. if (!pd) {
  17. /* too early to use dev_name(), may not be registered */
  18. printk(KERN_ERR "%s: no platform data supplied\n", pdev->name);
  19. return NULL;
  20. }
  21. npd = kmemdup(pd, pdsize, GFP_KERNEL);
  22. if (!npd)
  23. return NULL;
  24. pdev->dev.platform_data = npd;
  25. return npd;
  26. }
  27. void s3c_sdhci_set_platdata(struct s3c_sdhci_platdata *pd,
  28. struct s3c_sdhci_platdata *set)
  29. {
  30. set->cd_type = pd->cd_type;
  31. set->ext_cd_init = pd->ext_cd_init;
  32. set->ext_cd_cleanup = pd->ext_cd_cleanup;
  33. set->ext_cd_gpio = pd->ext_cd_gpio;
  34. set->ext_cd_gpio_invert = pd->ext_cd_gpio_invert;
  35. if (pd->max_width)
  36. set->max_width = pd->max_width;
  37. if (pd->cfg_gpio)
  38. set->cfg_gpio = pd->cfg_gpio;
  39. if (pd->host_caps)
  40. set->host_caps |= pd->host_caps;
  41. if (pd->host_caps2)
  42. set->host_caps2 |= pd->host_caps2;
  43. if (pd->pm_caps)
  44. set->pm_caps |= pd->pm_caps;
  45. }