Tony Li | 1477858 | 2007-08-17 10:35:59 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * Tony Li <tony.li@freescale.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation; |
| 9 | */ |
| 10 | |
| 11 | #include <common.h> |
| 12 | #include <i2c.h> |
| 13 | #include <asm/io.h> |
| 14 | |
| 15 | #include "pq-mds-pib.h" |
| 16 | |
| 17 | int pib_init(void) |
| 18 | { |
| 19 | u8 val8; |
| 20 | u8 orig_i2c_bus; |
| 21 | |
| 22 | /* Switch temporarily to I2C bus #2 */ |
| 23 | orig_i2c_bus = i2c_get_bus_num(); |
| 24 | i2c_set_bus_num(1); |
Kim Phillips | 5aa4ad8 | 2007-08-16 22:52:59 -0500 | [diff] [blame] | 25 | |
| 26 | val8 = 0; |
Tony Li | 1477858 | 2007-08-17 10:35:59 +0800 | [diff] [blame] | 27 | #if defined(CONFIG_PCI) && !defined(CONFIG_PCISLAVE) |
| 28 | /* Assign PIB PMC slot to desired PCI bus */ |
Tony Li | 1477858 | 2007-08-17 10:35:59 +0800 | [diff] [blame] | 29 | i2c_write(0x23, 0x6, 1, &val8, 1); |
| 30 | i2c_write(0x23, 0x7, 1, &val8, 1); |
| 31 | val8 = 0xff; |
| 32 | i2c_write(0x23, 0x2, 1, &val8, 1); |
| 33 | i2c_write(0x23, 0x3, 1, &val8, 1); |
| 34 | |
| 35 | val8 = 0; |
| 36 | i2c_write(0x26, 0x6, 1, &val8, 1); |
| 37 | val8 = 0x34; |
| 38 | i2c_write(0x26, 0x7, 1, &val8, 1); |
| 39 | #if defined(CONFIG_MPC832XEMDS) |
| 40 | val8 = 0xf9; /* PMC2, PMC3 slot to PCI bus */ |
| 41 | #else |
| 42 | val8 = 0xf3; /* PMC1, PMC2, PMC3 slot to PCI bus */ |
| 43 | #endif |
| 44 | i2c_write(0x26, 0x2, 1, &val8, 1); |
| 45 | val8 = 0xff; |
| 46 | i2c_write(0x26, 0x3, 1, &val8, 1); |
| 47 | |
| 48 | val8 = 0; |
| 49 | i2c_write(0x27, 0x6, 1, &val8, 1); |
| 50 | i2c_write(0x27, 0x7, 1, &val8, 1); |
| 51 | val8 = 0xff; |
| 52 | i2c_write(0x27, 0x2, 1, &val8, 1); |
| 53 | val8 = 0xef; |
| 54 | i2c_write(0x27, 0x3, 1, &val8, 1); |
| 55 | |
| 56 | eieio(); |
| 57 | |
| 58 | #if defined(CONFIG_MPC832XEMDS) |
| 59 | printf("PCI 32bit bus on PMC2 &PMC3\n"); |
| 60 | #else |
| 61 | printf("PCI 32bit bus on PMC1 & PMC2 &PMC3\n"); |
| 62 | #endif |
| 63 | #endif |
| 64 | |
| 65 | #if defined(CONFIG_PQ_MDS_PIB_ATM) |
York Sun | 3759b5b | 2016-11-16 11:36:32 -0800 | [diff] [blame^] | 66 | #if defined(CONFIG_TARGET_MPC8569MDS) |
Tony Li | 1477858 | 2007-08-17 10:35:59 +0800 | [diff] [blame] | 67 | val8 = 0; |
| 68 | i2c_write(0x20, 0x6, 1, &val8, 1); |
| 69 | i2c_write(0x20, 0x7, 1, &val8, 1); |
| 70 | |
| 71 | val8 = 0xdf; |
| 72 | i2c_write(0x20, 0x2, 1, &val8, 1); |
| 73 | val8 = 0xf7; |
| 74 | i2c_write(0x20, 0x3, 1, &val8, 1); |
| 75 | |
| 76 | eieio(); |
| 77 | |
| 78 | printf("QOC3 ATM card on PMC0\n"); |
| 79 | #elif defined(CONFIG_MPC832XEMDS) |
Tony Li | d264655 | 2007-10-18 17:44:38 +0800 | [diff] [blame] | 80 | val8 = 0; |
| 81 | i2c_write(0x26, 0x7, 1, &val8, 1); |
| 82 | val8 = 0xf7; |
| 83 | i2c_write(0x26, 0x3, 1, &val8, 1); |
Tony Li | 1477858 | 2007-08-17 10:35:59 +0800 | [diff] [blame] | 84 | |
Tony Li | d264655 | 2007-10-18 17:44:38 +0800 | [diff] [blame] | 85 | val8 = 0; |
| 86 | i2c_write(0x21, 0x6, 1, &val8, 1); |
| 87 | i2c_write(0x21, 0x7, 1, &val8, 1); |
Tony Li | 1477858 | 2007-08-17 10:35:59 +0800 | [diff] [blame] | 88 | |
Tony Li | d264655 | 2007-10-18 17:44:38 +0800 | [diff] [blame] | 89 | val8 = 0xdf; |
| 90 | i2c_write(0x21, 0x2, 1, &val8, 1); |
| 91 | val8 = 0xef; |
| 92 | i2c_write(0x21, 0x3, 1, &val8, 1); |
Tony Li | 1477858 | 2007-08-17 10:35:59 +0800 | [diff] [blame] | 93 | |
| 94 | eieio(); |
| 95 | |
| 96 | printf("QOC3 ATM card on PMC1\n"); |
| 97 | #endif |
| 98 | #endif |
| 99 | /* Reset to original I2C bus */ |
| 100 | i2c_set_bus_num(orig_i2c_bus); |
| 101 | return 0; |
| 102 | } |