From patchwork Tue Jun 23 04:26:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Herrenschmidt X-Patchwork-Id: 487498 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 836A71401AD for ; Tue, 23 Jun 2015 14:26:42 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 69EAB1A0F82 for ; Tue, 23 Jun 2015 14:26:42 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 634561A0F41 for ; Tue, 23 Jun 2015 14:26:25 +1000 (AEST) Received: from pasglop.ozlabs.ibm.com (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.13.8) with ESMTP id t5N4Q2mT029011; Mon, 22 Jun 2015 23:26:16 -0500 From: Benjamin Herrenschmidt To: skiboot@lists.ozlabs.org Date: Tue, 23 Jun 2015 14:26:00 +1000 Message-Id: <1435033560-9180-10-git-send-email-benh@kernel.crashing.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435033560-9180-1-git-send-email-benh@kernel.crashing.org> References: <1435033560-9180-1-git-send-email-benh@kernel.crashing.org> Subject: [Skiboot] [PATCH 10/10] p8-i2c: Keep centaur OCC cache disabled during inits X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" To avoid possible XSCOM collisions Signed-off-by: Benjamin Herrenschmidt --- hw/p8-i2c.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c index 510604a..5295ad8 100644 --- a/hw/p8-i2c.c +++ b/hw/p8-i2c.c @@ -866,7 +866,8 @@ static int p8_i2c_start_request(struct p8_i2c_master *master, DBG("Disabling OCC cache...\n"); rc = centaur_disable_sensor_cache(master->chip_id); if (rc < 0) { - log_simple_error(&e_info(OPAL_RC_I2C_START_REQ), "I2C: Failed " + log_simple_error(&e_info(OPAL_RC_I2C_START_REQ), + "I2C: Failed " "to disable the sensor cache\n"); return rc; } @@ -1225,7 +1226,7 @@ static void p8_i2c_init_one(struct dt_node *i2cm, enum p8_i2c_master_type type) struct list_head *chip_list; uint64_t ex_stat; static bool irq_printed; - int rc; + int64_t rc; master = zalloc(sizeof(*master)); if (!master) { @@ -1254,6 +1255,10 @@ static void p8_i2c_init_one(struct dt_node *i2cm, enum p8_i2c_master_type type) struct centaur_chip *centaur = get_centaur(master->chip_id); assert(centaur); chip_list = ¢aur->i2cms; + + /* Detect bad device-tree from HostBoot giving us bogus + * i2c masters + */ if (master->engine_id > 0) { prlog(PR_ERR, "I2C: Skipping Centaur Master #1\n"); free(master); @@ -1272,11 +1277,24 @@ static void p8_i2c_init_one(struct dt_node *i2cm, enum p8_i2c_master_type type) prlog(PR_INFO, "I2C: Chip %08x Eng. %d\n", master->chip_id, master->engine_id); + /* Disable OCC cache during inits */ + if (master->type == I2C_CENTAUR) { + rc = centaur_disable_sensor_cache(master->chip_id); + if (rc < 0) { + log_simple_error(&e_info(OPAL_RC_I2C_INIT), "I2C: " + "Error %lld disabling sensor cache\n", + rc); + /* Ignore error and move on ... */ + } else + time_wait(rc); + } rc = xscom_read(master->chip_id, master->xscom_base + I2C_EXTD_STAT_REG, &ex_stat); if (rc) { log_simple_error(&e_info(OPAL_RC_I2C_INIT), "I2C: " "Failed to read EXTD_STAT_REG\n"); + if (master->type == I2C_CENTAUR) + centaur_enable_sensor_cache(master->chip_id); free(master); return; } @@ -1294,6 +1312,12 @@ static void p8_i2c_init_one(struct dt_node *i2cm, enum p8_i2c_master_type type) /* Program the watermark register */ rc = p8_i2c_prog_watermark(master); + + /* Re-enable the sensor cache, we aren't touching HW anymore */ + if (master->type == I2C_CENTAUR) + centaur_enable_sensor_cache(master->chip_id); + + /* Handle errors from p8_i2c_prog_watermark */ if (rc) { log_simple_error(&e_info(OPAL_RC_I2C_INIT), "I2C: Failed to program the "