fb.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * arch/arm/mach-netx/fb.c
  3. *
  4. * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2
  8. * as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/device.h>
  20. #include <linux/init.h>
  21. #include <linux/dma-mapping.h>
  22. #include <linux/amba/bus.h>
  23. #include <linux/amba/clcd.h>
  24. #include <linux/err.h>
  25. #include <asm/irq.h>
  26. #include <mach/netx-regs.h>
  27. #include <mach/hardware.h>
  28. static struct clcd_panel *netx_panel;
  29. void netx_clcd_enable(struct clcd_fb *fb)
  30. {
  31. }
  32. int netx_clcd_setup(struct clcd_fb *fb)
  33. {
  34. dma_addr_t dma;
  35. fb->panel = netx_panel;
  36. fb->fb.screen_base = dma_alloc_writecombine(&fb->dev->dev, 1024*1024,
  37. &dma, GFP_KERNEL);
  38. if (!fb->fb.screen_base) {
  39. printk(KERN_ERR "CLCD: unable to map framebuffer\n");
  40. return -ENOMEM;
  41. }
  42. fb->fb.fix.smem_start = dma;
  43. fb->fb.fix.smem_len = 1024*1024;
  44. return 0;
  45. }
  46. int netx_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
  47. {
  48. return dma_mmap_writecombine(&fb->dev->dev, vma,
  49. fb->fb.screen_base,
  50. fb->fb.fix.smem_start,
  51. fb->fb.fix.smem_len);
  52. }
  53. void netx_clcd_remove(struct clcd_fb *fb)
  54. {
  55. dma_free_writecombine(&fb->dev->dev, fb->fb.fix.smem_len,
  56. fb->fb.screen_base, fb->fb.fix.smem_start);
  57. }
  58. void clk_disable(struct clk *clk)
  59. {
  60. }
  61. int clk_set_rate(struct clk *clk, unsigned long rate)
  62. {
  63. return 0;
  64. }
  65. int clk_enable(struct clk *clk)
  66. {
  67. return 0;
  68. }
  69. struct clk *clk_get(struct device *dev, const char *id)
  70. {
  71. return dev && strcmp(dev_name(dev), "fb") == 0 ? NULL : ERR_PTR(-ENOENT);
  72. }
  73. void clk_put(struct clk *clk)
  74. {
  75. }
  76. static struct amba_device fb_device = {
  77. .dev = {
  78. .init_name = "fb",
  79. .coherent_dma_mask = ~0,
  80. },
  81. .res = {
  82. .start = 0x00104000,
  83. .end = 0x00104fff,
  84. .flags = IORESOURCE_MEM,
  85. },
  86. .irq = { NETX_IRQ_LCD, NO_IRQ },
  87. .periphid = 0x10112400,
  88. };
  89. int netx_fb_init(struct clcd_board *board, struct clcd_panel *panel)
  90. {
  91. netx_panel = panel;
  92. fb_device.dev.platform_data = board;
  93. return amba_device_register(&fb_device, &iomem_resource);
  94. }