amba.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. void *lcd_base;
  31. void *lcd_console_address;
  32. short console_col;
  33. short console_row;
  34. /*
  35. * To use this driver you need to provide the following in board files:
  36. * a panel_info definition
  37. * an lcd_enable function (can't define a weak default with current code)
  38. */
  39. /* There is nothing to do with color registers, we use true color */
  40. void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
  41. {
  42. return;
  43. }
  44. /* Low level initialization of the logic cell: depends on panel_info */
  45. void lcd_ctrl_init(void *lcdbase)
  46. {
  47. struct clcd_config *config;
  48. struct clcd_registers *regs;
  49. u32 cntl;
  50. config = panel_info.priv;
  51. regs = config->address;
  52. cntl = config->cntl & ~CNTL_LCDEN;
  53. /* Lazily, just copy the registers over: first control with disable */
  54. writel(cntl, &regs->cntl);
  55. writel(config->tim0, &regs->tim0);
  56. writel(config->tim1, &regs->tim1);
  57. writel(config->tim2, &regs->tim2);
  58. writel(config->tim3, &regs->tim3);
  59. writel((u32)lcdbase, &regs->ubas);
  60. /* finally, enable */
  61. writel(cntl | CNTL_LCDEN, &regs->cntl);
  62. }
  63. /* This is trivial, and copied from atmel_lcdfb.c */
  64. ulong calc_fbsize(void)
  65. {
  66. return ((panel_info.vl_col * panel_info.vl_row *
  67. NBITS(panel_info.vl_bpix)) / 8) + PAGE_SIZE;
  68. }