amba.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Driver for AMBA PrimeCell CLCD
  3. *
  4. * Copyright (C) 2009 Alessandro Rubini
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. #include <common.h>
  25. #include <asm/io.h>
  26. #include <lcd.h>
  27. #include <amba_clcd.h>
  28. /* These variables are required by lcd.c -- although it sets them by itself */
  29. int lcd_line_length;
  30. int lcd_color_fg;
  31. int lcd_color_bg;
  32. void *lcd_base;
  33. void *lcd_console_address;
  34. short console_col;
  35. short console_row;
  36. /*
  37. * To use this driver you need to provide the following in board files:
  38. * a panel_info definition
  39. * an lcd_enable function (can't define a weak default with current code)
  40. */
  41. /* There is nothing to do with color registers, we use true color */
  42. void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
  43. {
  44. return;
  45. }
  46. /* Low level initialization of the logic cell: depends on panel_info */
  47. void lcd_ctrl_init(void *lcdbase)
  48. {
  49. struct clcd_config *config;
  50. struct clcd_registers *regs;
  51. u32 cntl;
  52. config = panel_info.priv;
  53. regs = config->address;
  54. cntl = config->cntl & ~CNTL_LCDEN;
  55. /* Lazily, just copy the registers over: first control with disable */
  56. writel(cntl, &regs->cntl);
  57. writel(config->tim0, &regs->tim0);
  58. writel(config->tim1, &regs->tim1);
  59. writel(config->tim2, &regs->tim2);
  60. writel(config->tim3, &regs->tim3);
  61. writel((u32)lcdbase, &regs->ubas);
  62. /* finally, enable */
  63. writel(cntl | CNTL_LCDEN, &regs->cntl);
  64. }
  65. /* This is trivial, and copied from atmel_lcdfb.c */
  66. ulong calc_fbsize(void)
  67. {
  68. return ((panel_info.vl_col * panel_info.vl_row *
  69. NBITS(panel_info.vl_bpix)) / 8) + PAGE_SIZE;
  70. }