Commit e2bee9e3c0f4bd363207ce5e496cef2134f67d28

Authored by Anatolij Gustschin
1 parent 1054382007

video: sm501: add support for SM501 chips on PCI bus

Signed-off-by: Anatolij Gustschin <agust@denx.de>

Showing 2 changed files with 85 additions and 5 deletions Side-by-side Diff

drivers/video/sm501.c
... ... @@ -31,6 +31,7 @@
31 31  
32 32 #include <common.h>
33 33  
  34 +#include <asm/io.h>
34 35 #include <video_fb.h>
35 36 #include <sm501.h>
36 37  
... ... @@ -54,6 +55,18 @@
54 55  
55 56 GraphicDevice sm501;
56 57  
  58 +void write_be32(int off, unsigned int val)
  59 +{
  60 + out_be32((unsigned __iomem *)(sm501.isaBase + off), val);
  61 +}
  62 +
  63 +void write_le32(int off, unsigned int val)
  64 +{
  65 + out_le32((unsigned __iomem *)(sm501.isaBase + off), val);
  66 +}
  67 +
  68 +void (*write_reg32)(int off, unsigned int val) = write_be32;
  69 +
57 70 /*-----------------------------------------------------------------------------
58 71 * SmiSetRegs --
59 72 *-----------------------------------------------------------------------------
... ... @@ -66,7 +79,7 @@
66 79 */
67 80 const SMI_REGS *preg = board_get_regs ();
68 81 while (preg->Index) {
69   - write32 (preg->Index, preg->Value);
  82 + write_reg32 (preg->Index, preg->Value);
70 83 /*
71 84 * Insert a delay between
72 85 */
73 86  
74 87  
75 88  
76 89  
... ... @@ -75,26 +88,92 @@
75 88 }
76 89 }
77 90  
  91 +#ifdef CONFIG_VIDEO_SM501_PCI
  92 +static struct pci_device_id sm501_pci_tbl[] = {
  93 + { PCI_VENDOR_ID_SMI, PCI_DEVICE_ID_SMI_501 },
  94 + {}
  95 +};
  96 +#endif
  97 +
78 98 /*-----------------------------------------------------------------------------
79 99 * video_hw_init --
80 100 *-----------------------------------------------------------------------------
81 101 */
82 102 void *video_hw_init (void)
83 103 {
  104 +#ifdef CONFIG_VIDEO_SM501_PCI
  105 + unsigned int pci_mem_base, pci_mmio_base;
  106 + unsigned int id;
  107 + unsigned short device_id;
  108 + pci_dev_t devbusfn;
  109 + int mem;
  110 +#endif
84 111 unsigned int *vm, i;
85 112  
86 113 memset (&sm501, 0, sizeof (GraphicDevice));
87 114  
  115 +#ifdef CONFIG_VIDEO_SM501_PCI
  116 + printf("Video: ");
  117 +
  118 + /* Look for SM501/SM502 chips */
  119 + devbusfn = pci_find_devices(sm501_pci_tbl, 0);
  120 + if (devbusfn < 0) {
  121 + printf ("PCI Controller not found.\n");
  122 + goto not_pci;
  123 + }
  124 +
  125 + /* Setup */
  126 + pci_write_config_dword (devbusfn, PCI_COMMAND,
  127 + (PCI_COMMAND_MEMORY | PCI_COMMAND_IO));
  128 + pci_read_config_word (devbusfn, PCI_DEVICE_ID, &device_id);
  129 + pci_read_config_dword (devbusfn, PCI_REVISION_ID, &id);
  130 + pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_0, &pci_mem_base);
  131 + pci_read_config_dword (devbusfn, PCI_BASE_ADDRESS_1, &pci_mmio_base);
  132 + sm501.frameAdrs = pci_mem_to_phys (devbusfn, pci_mem_base);
  133 + sm501.isaBase = pci_mem_to_phys (devbusfn, pci_mmio_base);
  134 +
  135 + if (sm501.isaBase)
  136 + write_reg32 = write_le32;
  137 +
  138 + mem = in_le32 ((unsigned __iomem *)(sm501.isaBase + 0x10));
  139 + mem = (mem & 0x0000e000) >> 13;
  140 + switch (mem) {
  141 + case 1:
  142 + mem = 8;
  143 + break;
  144 + case 2:
  145 + mem = 16;
  146 + break;
  147 + case 3:
  148 + mem = 32;
  149 + break;
  150 + case 4:
  151 + mem = 64;
  152 + break;
  153 + case 5:
  154 + mem = 2;
  155 + break;
  156 + case 0:
  157 + default:
  158 + mem = 4;
  159 + }
  160 + printf ("PCI SM50%d %d MB\n", ((id & 0xff) == 0xC0) ? 2 : 1, mem);
  161 +not_pci:
  162 +#endif
88 163 /*
89 164 * Initialization of the access to the graphic chipset Retreive base
90 165 * address of the chipset (see board/RPXClassic/eccx.c)
91 166 */
92   - if ((sm501.isaBase = board_video_init ()) == 0) {
93   - return (NULL);
  167 + if (!sm501.isaBase) {
  168 + sm501.isaBase = board_video_init ();
  169 + if (!sm501.isaBase)
  170 + return NULL;
94 171 }
95 172  
96   - if ((sm501.frameAdrs = board_video_get_fb ()) == 0) {
97   - return (NULL);
  173 + if (!sm501.frameAdrs) {
  174 + sm501.frameAdrs = board_video_get_fb ();
  175 + if (!sm501.frameAdrs)
  176 + return NULL;
98 177 }
99 178  
100 179 sm501.winSizeX = board_get_width ();
... ... @@ -1454,6 +1454,7 @@
1454 1454 #define PCI_DEVICE_ID_SMI_710 0x0710
1455 1455 #define PCI_DEVICE_ID_SMI_712 0x0712
1456 1456 #define PCI_DEVICE_ID_SMI_810 0x0810
  1457 +#define PCI_DEVICE_ID_SMI_501 0x0501
1457 1458  
1458 1459 #define PCI_VENDOR_ID_HUGHES 0x1273
1459 1460 #define PCI_DEVICE_ID_HUGHES_DIRECPC 0x0002