2013-10-07 10:57:42 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the coreboot project.
|
|
|
|
*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SOC_NVIDIA_TEGRA_I2C_H__
|
|
|
|
#define __SOC_NVIDIA_TEGRA_I2C_H__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
void i2c_init(unsigned bus);
|
2014-05-06 03:03:46 +02:00
|
|
|
void tegra_software_i2c_init(unsigned bus);
|
|
|
|
void tegra_software_i2c_disable(unsigned bus);
|
2013-10-07 10:57:42 +02:00
|
|
|
|
|
|
|
enum {
|
|
|
|
/* Word 0 */
|
2013-10-10 08:45:07 +02:00
|
|
|
IOHEADER_PROTHDRSZ_SHIFT = 28,
|
|
|
|
IOHEADER_PROTHDRSZ_MASK = 0x3 << IOHEADER_PROTHDRSZ_SHIFT,
|
|
|
|
IOHEADER_PKTID_SHIFT = 16,
|
|
|
|
IOHEADER_PKTID_MASK = 0xff << IOHEADER_PKTID_SHIFT,
|
|
|
|
IOHEADER_CONTROLLER_ID_SHIFT = 12,
|
|
|
|
IOHEADER_CONTROLLER_ID_MASK = 0xf << IOHEADER_CONTROLLER_ID_SHIFT,
|
|
|
|
IOHEADER_PROTOCOL_SHIFT = 4,
|
|
|
|
IOHEADER_PROTOCOL_MASK = 0xf << IOHEADER_PROTOCOL_SHIFT,
|
|
|
|
IOHEADER_PROTOCOL_I2C = 1 << IOHEADER_PROTOCOL_SHIFT,
|
|
|
|
IOHEADER_PKTTYPE_SHIFT = 0,
|
|
|
|
IOHEADER_PKTTYPE_MASK = 0x7 << IOHEADER_PKTTYPE_SHIFT,
|
|
|
|
IOHEADER_PKTTYPE_REQUEST = 0 << IOHEADER_PKTTYPE_SHIFT,
|
|
|
|
IOHEADER_PKTTYPE_RESPONSE = 1 << IOHEADER_PKTTYPE_SHIFT,
|
|
|
|
IOHEADER_PKTTYPE_INTERRUPT = 2 << IOHEADER_PKTTYPE_SHIFT,
|
|
|
|
IOHEADER_PKTTYPE_STOP = 3 << IOHEADER_PKTTYPE_SHIFT,
|
2013-10-07 10:57:42 +02:00
|
|
|
|
|
|
|
/* Word 1 */
|
2013-10-10 08:45:07 +02:00
|
|
|
IOHEADER_PAYLOADSIZE_SHIFT = 0,
|
|
|
|
IOHEADER_PAYLOADSIZE_MASK = 0xfff << IOHEADER_PAYLOADSIZE_SHIFT
|
2013-10-07 10:57:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2013-10-10 08:45:07 +02:00
|
|
|
IOHEADER_I2C_REQ_RESP_FREQ_MASK = 0x1 << 25,
|
|
|
|
IOHEADER_I2C_REQ_RESP_FREQ_END = 0 << 25,
|
|
|
|
IOHEADER_I2C_REQ_RESP_FREQ_EACH = 1 << 25,
|
|
|
|
IOHEADER_I2C_REQ_RESP_ENABLE = 0x1 << 24,
|
|
|
|
IOHEADER_I2C_REQ_HS_MODE = 0x1 << 22,
|
|
|
|
IOHEADER_I2C_REQ_CONTINUE_ON_NACK = 0x1 << 21,
|
|
|
|
IOHEADER_I2C_REQ_SEND_START_BYTE = 0x1 << 20,
|
|
|
|
IOHEADER_I2C_REQ_READ = 0x1 << 19,
|
|
|
|
IOHEADER_I2C_REQ_ADDR_MODE_MASK = 0x1 << 18,
|
|
|
|
IOHEADER_I2C_REQ_ADDR_MODE_7BIT = 0 << 18,
|
|
|
|
IOHEADER_I2C_REQ_ADDR_MODE_10BIT = 1 << 18,
|
|
|
|
IOHEADER_I2C_REQ_IE = 0x1 << 17,
|
|
|
|
IOHEADER_I2C_REQ_REPEAT_START = 0x1 << 16,
|
|
|
|
IOHEADER_I2C_REQ_STOP = 0x0 << 16,
|
|
|
|
IOHEADER_I2C_REQ_CONTINUE_XFER = 0x1 << 15,
|
|
|
|
IOHEADER_I2C_REQ_HS_MASTER_ADDR_SHIFT = 12,
|
|
|
|
IOHEADER_I2C_REQ_HS_MASTER_ADDR_MASK =
|
|
|
|
0x7 << IOHEADER_I2C_REQ_HS_MASTER_ADDR_SHIFT,
|
|
|
|
IOHEADER_I2C_REQ_SLAVE_ADDR_SHIFT = 0,
|
|
|
|
IOHEADER_I2C_REQ_SLAVE_ADDR_MASK =
|
|
|
|
0x3ff << IOHEADER_I2C_REQ_SLAVE_ADDR_SHIFT
|
2013-10-07 10:57:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2013-10-10 08:45:07 +02:00
|
|
|
I2C_CNFG_MSTR_CLR_BUS_ON_TIMEOUT = 0x1 << 15,
|
|
|
|
I2C_CNFG_DEBOUNCE_CNT_SHIFT = 12,
|
|
|
|
I2C_CNFG_DEBOUNCE_CNT_MASK = 0x7 << I2C_CNFG_DEBOUNCE_CNT_SHIFT,
|
|
|
|
I2C_CNFG_NEW_MASTER_FSM = 0x1 << 11,
|
|
|
|
I2C_CNFG_PACKET_MODE_EN = 0x1 << 10,
|
|
|
|
I2C_CNFG_SEND = 0x1 << 9,
|
|
|
|
I2C_CNFG_NOACK = 0x1 << 8,
|
|
|
|
I2C_CNFG_CMD2 = 0x1 << 7,
|
|
|
|
I2C_CNFG_CMD1 = 0x1 << 6,
|
|
|
|
I2C_CNFG_START = 0x1 << 5,
|
|
|
|
I2C_CNFG_SLV2_SHIFT = 4,
|
|
|
|
I2C_CNFG_SLV2_MASK = 0x1 << I2C_CNFG_SLV2_SHIFT,
|
|
|
|
I2C_CNFG_LENGTH_SHIFT = 1,
|
|
|
|
I2C_CNFG_LENGTH_MASK = 0x7 << I2C_CNFG_LENGTH_SHIFT,
|
|
|
|
I2C_CNFG_A_MOD = 0x1 << 0,
|
2013-10-07 10:57:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2013-10-10 08:45:07 +02:00
|
|
|
I2C_PKT_STATUS_COMPLETE = 0x1 << 24,
|
|
|
|
I2C_PKT_STATUS_PKT_ID_SHIFT = 16,
|
|
|
|
I2C_PKT_STATUS_PKT_ID_MASK = 0xff << I2C_PKT_STATUS_PKT_ID_SHIFT,
|
|
|
|
I2C_PKT_STATUS_BYTENUM_SHIFT = 4,
|
|
|
|
I2C_PKT_STATUS_BYTENUM_MASK = 0xfff << I2C_PKT_STATUS_BYTENUM_SHIFT,
|
|
|
|
I2C_PKT_STATUS_NOACK_ADDR = 0x1 << 3,
|
|
|
|
I2C_PKT_STATUS_NOACK_DATA = 0x1 << 2,
|
|
|
|
I2C_PKT_STATUS_ARB_LOST = 0x1 << 1,
|
|
|
|
I2C_PKT_STATUS_BUSY = 0x1 << 0
|
2013-10-07 10:57:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2013-10-10 08:45:07 +02:00
|
|
|
I2C_FIFO_STATUS_TX_FIFO_EMPTY_CNT_SHIFT = 4,
|
|
|
|
I2C_FIFO_STATUS_TX_FIFO_EMPTY_CNT_MASK =
|
|
|
|
0xf << I2C_FIFO_STATUS_TX_FIFO_EMPTY_CNT_SHIFT,
|
|
|
|
I2C_FIFO_STATUS_RX_FIFO_FULL_CNT_SHIFT = 0,
|
|
|
|
I2C_FIFO_STATUS_RX_FIFO_FULL_CNT_MASK =
|
|
|
|
0xf << I2C_FIFO_STATUS_RX_FIFO_FULL_CNT_SHIFT
|
2013-10-07 10:57:42 +02:00
|
|
|
};
|
|
|
|
|
nyan*: I2C: Implement bus clear when 'ARB_LOST' error occurs
This is a fix for the 'Lost arb' we're seeing on Nyan* during
reboot stress testing. It occurs when we are slamming the
default PMIC registers with pmic_write_reg().
Currently, I've only captured this a few times, and the bus
clear seemed to work, as the PMIC writes continued (where
they'd hang the system before bus clear) for a couple of regs,
then it hangs hard, no messages, no 2nd lost arb, etc. So
I've added code to the PMIC write function that will reset the
SoC if any I2C error occurs. That seems to recover OK, i.e. on
the next reboot the PMIC writes all go thru, boot is OK, kernel
loads, etc.
BUG=chrome-os-partner:28323
BRANCH=nyan
TEST=Tested on nyan. Built for nyan and nyan_big.
Original-Change-Id: I1ac5e3023ae22c015105b7f0fb7849663b4aa982
Original-Signed-off-by: Tom Warren <twarren@nvidia.com>
Original-Reviewed-on: https://chromium-review.googlesource.com/197732
Original-Reviewed-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-by: Jimmy Zhang <jimmzhang@nvidia.com>
(cherry picked from commit f445127e2d9e223a5ef9117008a7ac7631a7980c)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: I584d55b99d65f1e278961db6bdde1845cb01f3bc
Reviewed-on: http://review.coreboot.org/7897
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2014-04-30 23:51:38 +02:00
|
|
|
enum {
|
|
|
|
I2C_BUS_CLEAR_CONFIG_BC_SCLK_THRESHOLD_SHIFT = 16,
|
|
|
|
I2C_BUS_CLEAR_CONFIG_BC_SCLK_THRESHOLD_MASK =
|
2014-07-02 18:25:35 +02:00
|
|
|
0xff << I2C_BUS_CLEAR_CONFIG_BC_SCLK_THRESHOLD_SHIFT,
|
nyan*: I2C: Implement bus clear when 'ARB_LOST' error occurs
This is a fix for the 'Lost arb' we're seeing on Nyan* during
reboot stress testing. It occurs when we are slamming the
default PMIC registers with pmic_write_reg().
Currently, I've only captured this a few times, and the bus
clear seemed to work, as the PMIC writes continued (where
they'd hang the system before bus clear) for a couple of regs,
then it hangs hard, no messages, no 2nd lost arb, etc. So
I've added code to the PMIC write function that will reset the
SoC if any I2C error occurs. That seems to recover OK, i.e. on
the next reboot the PMIC writes all go thru, boot is OK, kernel
loads, etc.
BUG=chrome-os-partner:28323
BRANCH=nyan
TEST=Tested on nyan. Built for nyan and nyan_big.
Original-Change-Id: I1ac5e3023ae22c015105b7f0fb7849663b4aa982
Original-Signed-off-by: Tom Warren <twarren@nvidia.com>
Original-Reviewed-on: https://chromium-review.googlesource.com/197732
Original-Reviewed-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-by: Jimmy Zhang <jimmzhang@nvidia.com>
(cherry picked from commit f445127e2d9e223a5ef9117008a7ac7631a7980c)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: I584d55b99d65f1e278961db6bdde1845cb01f3bc
Reviewed-on: http://review.coreboot.org/7897
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2014-04-30 23:51:38 +02:00
|
|
|
I2C_BUS_CLEAR_CONFIG_BC_STOP_COND_STOP = 0x1 << 2,
|
2014-07-02 18:25:35 +02:00
|
|
|
I2C_BUS_CLEAR_CONFIG_BC_TERMINATE_IMMEDIATE = 0x1 << 1,
|
nyan*: I2C: Implement bus clear when 'ARB_LOST' error occurs
This is a fix for the 'Lost arb' we're seeing on Nyan* during
reboot stress testing. It occurs when we are slamming the
default PMIC registers with pmic_write_reg().
Currently, I've only captured this a few times, and the bus
clear seemed to work, as the PMIC writes continued (where
they'd hang the system before bus clear) for a couple of regs,
then it hangs hard, no messages, no 2nd lost arb, etc. So
I've added code to the PMIC write function that will reset the
SoC if any I2C error occurs. That seems to recover OK, i.e. on
the next reboot the PMIC writes all go thru, boot is OK, kernel
loads, etc.
BUG=chrome-os-partner:28323
BRANCH=nyan
TEST=Tested on nyan. Built for nyan and nyan_big.
Original-Change-Id: I1ac5e3023ae22c015105b7f0fb7849663b4aa982
Original-Signed-off-by: Tom Warren <twarren@nvidia.com>
Original-Reviewed-on: https://chromium-review.googlesource.com/197732
Original-Reviewed-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-by: Jimmy Zhang <jimmzhang@nvidia.com>
(cherry picked from commit f445127e2d9e223a5ef9117008a7ac7631a7980c)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: I584d55b99d65f1e278961db6bdde1845cb01f3bc
Reviewed-on: http://review.coreboot.org/7897
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2014-04-30 23:51:38 +02:00
|
|
|
I2C_BUS_CLEAR_CONFIG_BC_ENABLE = 0x1 << 0,
|
|
|
|
|
|
|
|
I2C_BUS_CLEAR_STATUS_CLEARED = 0x1 << 0,
|
|
|
|
|
|
|
|
I2C_CONFIG_LOAD_MSTR_CONFIG_LOAD_ENABLE = 0x1 << 0
|
|
|
|
};
|
|
|
|
|
2014-03-27 05:43:53 +01:00
|
|
|
struct tegra_i2c_bus_info {
|
|
|
|
void *base;
|
|
|
|
uint32_t reset_bit;
|
|
|
|
void (*reset_func)(u32 bit);
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct tegra_i2c_bus_info tegra_i2c_info[];
|
2013-10-07 10:57:42 +02:00
|
|
|
|
|
|
|
struct tegra_i2c_regs {
|
|
|
|
uint32_t cnfg;
|
|
|
|
uint32_t cmd_addr0;
|
|
|
|
uint32_t cmd_addr1;
|
|
|
|
uint32_t cmd_data1;
|
|
|
|
uint32_t cmd_data2;
|
|
|
|
uint8_t _rsv0[8];
|
|
|
|
uint32_t status;
|
|
|
|
uint32_t sl_cnfg;
|
|
|
|
uint32_t sl_rcvd;
|
|
|
|
uint32_t sl_status;
|
|
|
|
uint32_t sl_addr1;
|
|
|
|
uint32_t sl_addr2;
|
|
|
|
uint32_t tlow_sext;
|
|
|
|
uint8_t _rsv1[4];
|
|
|
|
uint32_t sl_delay_count;
|
|
|
|
uint32_t sl_int_mask;
|
|
|
|
uint32_t sl_int_source;
|
|
|
|
uint32_t sl_int_set;
|
|
|
|
uint8_t _rsv2[4];
|
|
|
|
uint32_t tx_packet_fifo;
|
|
|
|
uint32_t rx_fifo;
|
|
|
|
uint32_t packet_transfer_status;
|
|
|
|
uint32_t fifo_control;
|
|
|
|
uint32_t fifo_status;
|
|
|
|
uint32_t interrupt_mask;
|
|
|
|
uint32_t interrupt_status;
|
|
|
|
uint32_t clk_divisor;
|
|
|
|
uint32_t interrupt_source;
|
|
|
|
uint32_t interrupt_set;
|
|
|
|
uint32_t slv_tx_packet_fifo;
|
|
|
|
uint32_t slv_rx_fifo;
|
|
|
|
uint32_t slv_packet_status;
|
|
|
|
uint32_t bus_clear_config;
|
|
|
|
uint32_t bus_clear_status;
|
nyan*: I2C: Implement bus clear when 'ARB_LOST' error occurs
This is a fix for the 'Lost arb' we're seeing on Nyan* during
reboot stress testing. It occurs when we are slamming the
default PMIC registers with pmic_write_reg().
Currently, I've only captured this a few times, and the bus
clear seemed to work, as the PMIC writes continued (where
they'd hang the system before bus clear) for a couple of regs,
then it hangs hard, no messages, no 2nd lost arb, etc. So
I've added code to the PMIC write function that will reset the
SoC if any I2C error occurs. That seems to recover OK, i.e. on
the next reboot the PMIC writes all go thru, boot is OK, kernel
loads, etc.
BUG=chrome-os-partner:28323
BRANCH=nyan
TEST=Tested on nyan. Built for nyan and nyan_big.
Original-Change-Id: I1ac5e3023ae22c015105b7f0fb7849663b4aa982
Original-Signed-off-by: Tom Warren <twarren@nvidia.com>
Original-Reviewed-on: https://chromium-review.googlesource.com/197732
Original-Reviewed-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-by: Jimmy Zhang <jimmzhang@nvidia.com>
(cherry picked from commit f445127e2d9e223a5ef9117008a7ac7631a7980c)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: I584d55b99d65f1e278961db6bdde1845cb01f3bc
Reviewed-on: http://review.coreboot.org/7897
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2014-04-30 23:51:38 +02:00
|
|
|
uint32_t config_load;
|
2013-10-07 10:57:42 +02:00
|
|
|
};
|
nyan*: I2C: Implement bus clear when 'ARB_LOST' error occurs
This is a fix for the 'Lost arb' we're seeing on Nyan* during
reboot stress testing. It occurs when we are slamming the
default PMIC registers with pmic_write_reg().
Currently, I've only captured this a few times, and the bus
clear seemed to work, as the PMIC writes continued (where
they'd hang the system before bus clear) for a couple of regs,
then it hangs hard, no messages, no 2nd lost arb, etc. So
I've added code to the PMIC write function that will reset the
SoC if any I2C error occurs. That seems to recover OK, i.e. on
the next reboot the PMIC writes all go thru, boot is OK, kernel
loads, etc.
BUG=chrome-os-partner:28323
BRANCH=nyan
TEST=Tested on nyan. Built for nyan and nyan_big.
Original-Change-Id: I1ac5e3023ae22c015105b7f0fb7849663b4aa982
Original-Signed-off-by: Tom Warren <twarren@nvidia.com>
Original-Reviewed-on: https://chromium-review.googlesource.com/197732
Original-Reviewed-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-by: Jimmy Zhang <jimmzhang@nvidia.com>
(cherry picked from commit f445127e2d9e223a5ef9117008a7ac7631a7980c)
Signed-off-by: Marc Jones <marc.jones@se-eng.com>
Change-Id: I584d55b99d65f1e278961db6bdde1845cb01f3bc
Reviewed-on: http://review.coreboot.org/7897
Tested-by: build bot (Jenkins)
Reviewed-by: David Hendricks <dhendrix@chromium.org>
2014-04-30 23:51:38 +02:00
|
|
|
check_member(tegra_i2c_regs, config_load, 0x8C);
|
2013-10-07 10:57:42 +02:00
|
|
|
|
|
|
|
#endif /* __SOC_NVIDIA_TEGRA_I2C_H__ */
|