Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 2 | /* |
Kim Phillips | 57a2af3 | 2009-07-18 18:42:13 -0500 | [diff] [blame] | 3 | * Copyright (C) 2006-2009 Freescale Semiconductor, Inc. |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
Simon Glass | 18afe10 | 2019-11-14 12:57:47 -0700 | [diff] [blame] | 6 | #include <init.h> |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 7 | #include <asm/mmu.h> |
Ira W. Snyder | 0da3a3d | 2008-08-22 11:00:13 -0700 | [diff] [blame] | 8 | #include <asm/io.h> |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 9 | #include <common.h> |
Ira W. Snyder | 0da3a3d | 2008-08-22 11:00:13 -0700 | [diff] [blame] | 10 | #include <mpc83xx.h> |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 11 | #include <pci.h> |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 12 | #include <i2c.h> |
Ira W. Snyder | 0da3a3d | 2008-08-22 11:00:13 -0700 | [diff] [blame] | 13 | #include <asm/fsl_i2c.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 14 | #include <linux/delay.h> |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 15 | |
Ira W. Snyder | 0da3a3d | 2008-08-22 11:00:13 -0700 | [diff] [blame] | 16 | static struct pci_region pci1_regions[] = { |
| 17 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 18 | bus_start: CONFIG_SYS_PCI1_MEM_BASE, |
| 19 | phys_start: CONFIG_SYS_PCI1_MEM_PHYS, |
| 20 | size: CONFIG_SYS_PCI1_MEM_SIZE, |
Ira W. Snyder | 0da3a3d | 2008-08-22 11:00:13 -0700 | [diff] [blame] | 21 | flags: PCI_REGION_MEM | PCI_REGION_PREFETCH |
| 22 | }, |
| 23 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 24 | bus_start: CONFIG_SYS_PCI1_IO_BASE, |
| 25 | phys_start: CONFIG_SYS_PCI1_IO_PHYS, |
| 26 | size: CONFIG_SYS_PCI1_IO_SIZE, |
Ira W. Snyder | 0da3a3d | 2008-08-22 11:00:13 -0700 | [diff] [blame] | 27 | flags: PCI_REGION_IO |
| 28 | }, |
| 29 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 30 | bus_start: CONFIG_SYS_PCI1_MMIO_BASE, |
| 31 | phys_start: CONFIG_SYS_PCI1_MMIO_PHYS, |
| 32 | size: CONFIG_SYS_PCI1_MMIO_SIZE, |
Ira W. Snyder | 0da3a3d | 2008-08-22 11:00:13 -0700 | [diff] [blame] | 33 | flags: PCI_REGION_MEM |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 34 | }, |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 35 | }; |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 36 | |
Ira W. Snyder | 0da3a3d | 2008-08-22 11:00:13 -0700 | [diff] [blame] | 37 | #ifdef CONFIG_MPC83XX_PCI2 |
| 38 | static struct pci_region pci2_regions[] = { |
| 39 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 40 | bus_start: CONFIG_SYS_PCI2_MEM_BASE, |
| 41 | phys_start: CONFIG_SYS_PCI2_MEM_PHYS, |
| 42 | size: CONFIG_SYS_PCI2_MEM_SIZE, |
Ira W. Snyder | 0da3a3d | 2008-08-22 11:00:13 -0700 | [diff] [blame] | 43 | flags: PCI_REGION_MEM | PCI_REGION_PREFETCH |
| 44 | }, |
| 45 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 46 | bus_start: CONFIG_SYS_PCI2_IO_BASE, |
| 47 | phys_start: CONFIG_SYS_PCI2_IO_PHYS, |
| 48 | size: CONFIG_SYS_PCI2_IO_SIZE, |
Ira W. Snyder | 0da3a3d | 2008-08-22 11:00:13 -0700 | [diff] [blame] | 49 | flags: PCI_REGION_IO |
| 50 | }, |
| 51 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 52 | bus_start: CONFIG_SYS_PCI2_MMIO_BASE, |
| 53 | phys_start: CONFIG_SYS_PCI2_MMIO_PHYS, |
| 54 | size: CONFIG_SYS_PCI2_MMIO_SIZE, |
Ira W. Snyder | 0da3a3d | 2008-08-22 11:00:13 -0700 | [diff] [blame] | 55 | flags: PCI_REGION_MEM |
| 56 | }, |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 57 | }; |
Ira W. Snyder | 0da3a3d | 2008-08-22 11:00:13 -0700 | [diff] [blame] | 58 | #endif |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 59 | |
Ira W. Snyder | 4adfd02 | 2008-08-22 11:00:15 -0700 | [diff] [blame] | 60 | #ifndef CONFIG_PCISLAVE |
Ira W. Snyder | 0da3a3d | 2008-08-22 11:00:13 -0700 | [diff] [blame] | 61 | void pib_init(void) |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 62 | { |
Ben Warren | c813550 | 2006-09-12 10:15:53 -0400 | [diff] [blame] | 63 | u8 val8, orig_i2c_bus; |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 64 | /* |
| 65 | * Assign PIB PMC slot to desired PCI bus |
| 66 | */ |
Ben Warren | c813550 | 2006-09-12 10:15:53 -0400 | [diff] [blame] | 67 | /* Switch temporarily to I2C bus #2 */ |
| 68 | orig_i2c_bus = i2c_get_bus_num(); |
Wolfgang Denk | 87b3d4b | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 69 | i2c_set_bus_num(1); |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 70 | |
| 71 | val8 = 0; |
| 72 | i2c_write(0x23, 0x6, 1, &val8, 1); |
| 73 | i2c_write(0x23, 0x7, 1, &val8, 1); |
| 74 | val8 = 0xff; |
| 75 | i2c_write(0x23, 0x2, 1, &val8, 1); |
| 76 | i2c_write(0x23, 0x3, 1, &val8, 1); |
| 77 | |
| 78 | val8 = 0; |
| 79 | i2c_write(0x26, 0x6, 1, &val8, 1); |
| 80 | val8 = 0x34; |
| 81 | i2c_write(0x26, 0x7, 1, &val8, 1); |
Mario Six | 258312f | 2019-01-21 09:17:51 +0100 | [diff] [blame] | 82 | #if defined(CONFIG_PCI_64BIT) |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 83 | val8 = 0xf4; /* PMC2:PCI1/64-bit */ |
Mario Six | 258312f | 2019-01-21 09:17:51 +0100 | [diff] [blame] | 84 | #elif defined(CONFIG_PCI_ALL_PCI1) |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 85 | val8 = 0xf3; /* PMC1:PCI1 PMC2:PCI1 PMC3:PCI1 */ |
Mario Six | 258312f | 2019-01-21 09:17:51 +0100 | [diff] [blame] | 86 | #elif defined(CONFIG_PCI_ONE_PCI1) |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 87 | val8 = 0xf9; /* PMC1:PCI1 PMC2:PCI2 PMC3:PCI2 */ |
| 88 | #else |
| 89 | val8 = 0xf5; /* PMC1:PCI1 PMC2:PCI1 PMC3:PCI2 */ |
| 90 | #endif |
| 91 | i2c_write(0x26, 0x2, 1, &val8, 1); |
| 92 | val8 = 0xff; |
| 93 | i2c_write(0x26, 0x3, 1, &val8, 1); |
| 94 | val8 = 0; |
| 95 | i2c_write(0x27, 0x6, 1, &val8, 1); |
| 96 | i2c_write(0x27, 0x7, 1, &val8, 1); |
| 97 | val8 = 0xff; |
| 98 | i2c_write(0x27, 0x2, 1, &val8, 1); |
| 99 | val8 = 0xef; |
| 100 | i2c_write(0x27, 0x3, 1, &val8, 1); |
| 101 | asm("eieio"); |
| 102 | |
Mario Six | 258312f | 2019-01-21 09:17:51 +0100 | [diff] [blame] | 103 | #if defined(CONFIG_PCI_64BIT) |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 104 | printf("PCI1: 64-bit on PMC2\n"); |
Mario Six | 258312f | 2019-01-21 09:17:51 +0100 | [diff] [blame] | 105 | #elif defined(CONFIG_PCI_ALL_PCI1) |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 106 | printf("PCI1: 32-bit on PMC1, PMC2, PMC3\n"); |
Mario Six | 258312f | 2019-01-21 09:17:51 +0100 | [diff] [blame] | 107 | #elif defined(CONFIG_PCI_ONE_PCI1) |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 108 | printf("PCI1: 32-bit on PMC1\n"); |
| 109 | printf("PCI2: 32-bit on PMC2, PMC3\n"); |
| 110 | #else |
| 111 | printf("PCI1: 32-bit on PMC1, PMC2\n"); |
| 112 | printf("PCI2: 32-bit on PMC3\n"); |
| 113 | #endif |
Ben Warren | c813550 | 2006-09-12 10:15:53 -0400 | [diff] [blame] | 114 | /* Reset to original I2C bus */ |
Timur Tabi | ab34754 | 2006-11-03 19:15:00 -0600 | [diff] [blame] | 115 | i2c_set_bus_num(orig_i2c_bus); |
Kumar Gala | c565189 | 2006-01-12 19:51:38 -0600 | [diff] [blame] | 116 | } |
| 117 | |
Ira W. Snyder | 4adfd02 | 2008-08-22 11:00:15 -0700 | [diff] [blame] | 118 | #endif /* CONFIG_PCISLAVE */ |