Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2224218imm; Sun, 9 Sep 2018 19:27:16 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZEFp0E2+N9bmXdWXF9BmvPO2fQBnPxX0Oow8cdTfDY4XrUN1iZjBfOql04jxN79IWX+jZD X-Received: by 2002:a63:ec43:: with SMTP id r3-v6mr8999444pgj.295.1536546436160; Sun, 09 Sep 2018 19:27:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536546436; cv=none; d=google.com; s=arc-20160816; b=YvSyCOl5y7WRaFeYXJ/N9ptl3z9tPWkisQz1G1VXJ6A8SWL8nUXxWMZM4BO/iyUgiQ LgpB7kZbqE+9LEyD+oyMIepWqtj1RoWbVQ4DYtE29y6si9OGUPKUbm2+wlImGvCoE+io AQTyITdvzdQdx/pA8FrU1lcTgeDxFRu2zNCiTWEphnFw7bQjybkZmX+qZuv8GYVt/W6n 94IukhmeLzPC30NT5dBB0fQorOJKzGuusvJWTaT6TWwYBSkK6ugpT3JCy9+GlFtYlpMO fOE359G5GHspJ+mWEiza6hvkonj/O/adHwFxw4aN2zcQR/acyGxNt11S2F0F3RU5BV3g P9Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=0Jh2T4iNgwJkzbvYAP63yn/Klla1LAuUcrQl1eNDtKo=; b=w8e7mqQvVKbs4LGJW/lqlGziZYN0wq0PF5Cpm1F2j2jQpOYREDu1XNVY3qpy5eTlyi YzArX1BhAe1qXxabkmVKwmxxqdazes3WLTC8dUUi0B0sZXB0MBHKANuz6QiOo71lGpx3 Fo8qX66t33IDW10UdRtI5uK6/ksKCdp0iUxbw3zlPNUZxZe3R2NK0QaPFN5ysc0foRWq vU/7/M21fcR9Na5FJPvUAMyq17tqTnoFlsgtEHl2aiVFGFa7ZwJ8pGGDnDlfGdXI6/bj Y9XWrGtjP6yjWOFiOHdD3ZPMR0wfBNWcVUnTOXXbvRBaWgInGAvzQHd+E30tV/xzQw9J HC+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fSvL+MHd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 37-v6si17059452ple.491.2018.09.09.19.27.00; Sun, 09 Sep 2018 19:27:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fSvL+MHd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726121AbeIJHQu (ORCPT + 99 others); Mon, 10 Sep 2018 03:16:50 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:33935 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725889AbeIJHQu (ORCPT ); Mon, 10 Sep 2018 03:16:50 -0400 Received: by mail-lj1-f194.google.com with SMTP id f8-v6so16573210ljk.1; Sun, 09 Sep 2018 19:25:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0Jh2T4iNgwJkzbvYAP63yn/Klla1LAuUcrQl1eNDtKo=; b=fSvL+MHdDopIcAtJTsFUbCGpd79ybzPlrf/+6ukC0NXCk9MJfZE6ZcEklkautwye1R sQJ9aQhK6N4ggC1gbUeZmYelhGhZp1pmH7XUta9c96MSiipNL2GiZpEF58yeBjzkx6h3 zpe91afZSOt8OJ8QEIGlGAz3DNBWtCVW1kkqGGEOkecGPQmuq8h1Kb0RNxXM3r67pF4A F9rcq1LZWKBMpS2EIY4lAjDDqyMFt2BwlwLa3YA/DAf1MjgEBpUedL9bEKD+uQUKere7 Q0R84tWC7+1onJUM3oqNGlU4NmVVX4ARwn+ZLp6Qb75uiicgLHbZbUyCJvDmWUJhu9zU dH5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0Jh2T4iNgwJkzbvYAP63yn/Klla1LAuUcrQl1eNDtKo=; b=BVulFeH0QXyxKGaLZty8KPrwScgJ4M23pWR2n6FbsW9HP1N/78Fe+Opxnf4E7bFWJX YInU47UIE8R884siiwv8nqtEptImmd/dfklJrVnHAGKpWqLV5xFv9jcVGBlAiivJdDVM AVckSiCJXObtrkh/zQZpyJ+SdPf6Z53wmDjriROLeAdL4saupj0xqFYiFeBLRY3Gv9b+ 2OnC0jv7wtBNQsz0Id/6iDW4NMtTkeTFTKyPS3bbSyZYj5ghXxmcUJddFRliwYowBPhQ 3CYMb5rygVJfU1oO5UvB7ND5FhK0c3AZvSyqVxpoeb/xusnW6UWJDP+D1PuZ7LetyOMq Skug== X-Gm-Message-State: APzg51ChHaVQ56UtGWtKzWjaEcGC7PZGFNnJgHcCBGJNQlA3QkMn7u4K 4nEF2RBcUrXndILBfQpi+y2TRGco X-Received: by 2002:a2e:8147:: with SMTP id t7-v6mr11423379ljg.32.1536536596141; Sun, 09 Sep 2018 16:43:16 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id h4-v6sm2355373lfj.69.2018.09.09.16.43.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Sep 2018 16:43:15 -0700 (PDT) From: Janusz Krzysztofik To: Tony Lindgren Cc: Linus Walleij , Aaro Koskinen , Janusz Krzysztofik , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] ARM: OMAP1: ams-delta: initialize latch2 pins to safe values Date: Mon, 10 Sep 2018 01:44:18 +0200 Message-Id: <20180909234419.31261-3-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180909234419.31261-1-jmkrzyszt@gmail.com> References: <20180820181333.2527-1-jmkrzyszt@gmail.com> <20180909234419.31261-1-jmkrzyszt@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Latch2 pins control a number of on-board devices, namely LCD, NAND, MODEM and CODEC. Those pins used to be initialized with safe values from init_machine before that operation was: 1) moved to late_initcall in preparation for conversion of latch2 to GPIO device - see commit f7519d8c8290 ("ARM: OMAP1: ams-delta: register latch dependent devices later"), 2) replaced with non-atomic initialization performed by means of gpio_request_array() - see commit 937eb4bb0058 ("ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio"), 3) made completely asynchronous by delegation of GPIO request operations performed on subsets of pins to respective device drivers in subsequent commits. One visible negative result of that disintegration was corrupt keyboard data reported by serio driver, recently fixed by commit 41f8fee385a0 ("ARM: OMAP1: ams-delta: Hog "keybrd_dataout" GPIO pin"). Moreover, initialization of LATCH2_PIN_MODEM_CODEC still performed with ams_delta_latch2_write() wrapper from late_init() is now done on not requested GPIO pin. Reintroduce atomic initialization of latch2 pins at machine_init to prevent from random values potentially corrupting NAND data or maybe even destroing other hardware. Also take care of MODEM/CODEC related pins so MODEM device probe succeeds even if latch2 GPIO device or dependent regulator is not ready and CODEC can be reached over the MODEM even if audio driver doesn't take control over LATCH2_PIN_MODEM_CODEC. Once done, remove the no longer needed GPIO based implementation of ams_delta_latch_write() and its frontend macro. Signed-off-by: Janusz Krzysztofik Reviewed-by: Linus Walleij --- arch/arm/mach-omap1/board-ams-delta.c | 52 +++++++++++++++++++++++------------ arch/arm/mach-omap1/board-ams-delta.h | 7 ----- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c index 2b90b543c030..1d451142248c 100644 --- a/arch/arm/mach-omap1/board-ams-delta.c +++ b/arch/arm/mach-omap1/board-ams-delta.c @@ -321,20 +321,6 @@ struct modem_private_data { static struct modem_private_data modem_priv; -void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value) -{ - int bit = 0; - u16 bitpos = 1 << bit; - - for (; bit < ngpio; bit++, bitpos = bitpos << 1) { - if (!(mask & bitpos)) - continue; - else - gpio_set_value(base + bit, (value & bitpos) != 0); - } -} -EXPORT_SYMBOL(ams_delta_latch_write); - static struct resource ams_delta_nand_resources[] = { [0] = { .start = OMAP1_MPUIO_BASE, @@ -680,6 +666,40 @@ static void __init omap_gpio_deps_init(void) modem_assign_irq(chip); } +/* + * Initialize latch2 pins with values which are safe for dependent on-board + * devices or useful for their successull initialization even before GPIO + * driver takes control over the latch pins: + * - LATCH2_PIN_LCD_VBLEN = 0 + * - LATCH2_PIN_LCD_NDISP = 0 Keep LCD device powered off before its + * driver takes control over it. + * - LATCH2_PIN_NAND_NCE = 0 + * - LATCH2_PIN_NAND_NWP = 0 Keep NAND device down and write- + * protected before its driver takes + * control over it. + * - LATCH2_PIN_KEYBRD_PWR = 0 Keep keyboard powered off before serio + * driver takes control over it. + * - LATCH2_PIN_KEYBRD_DATAOUT = 0 Keep low to avoid corruption of first + * byte of data received from attached + * keyboard when serio device is probed; + * the pin is also hogged low by the latch2 + * GPIO driver as soon as it is ready. + * - LATCH2_PIN_MODEM_NRESET = 1 Enable voice MODEM device, allowing for + * its successful probe even before a + * regulator it depends on, which in turn + * takes control over the pin, is set up. + * - LATCH2_PIN_MODEM_CODEC = 1 Attach voice MODEM CODEC data port + * to the MODEM so the CODEC is under + * control even if audio driver doesn't + * take it over. + */ +static void __init ams_delta_latch2_init(void) +{ + u16 latch2 = 1 << LATCH2_PIN_MODEM_NRESET | 1 << LATCH2_PIN_MODEM_CODEC; + + __raw_writew(latch2, LATCH2_VIRT); +} + static void __init ams_delta_init(void) { /* mux pins for uarts */ @@ -701,6 +721,7 @@ static void __init ams_delta_init(void) omap_cfg_reg(J18_1610_CAM_D7); omap_gpio_deps_init(); + ams_delta_latch2_init(); gpiod_add_hogs(ams_delta_gpio_hogs); omap_serial_init(); @@ -888,9 +909,6 @@ static int __init ams_delta_modem_init(void) /* Initialize the modem_nreset regulator consumer before use */ modem_priv.regulator = ERR_PTR(-ENODEV); - ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, - AMS_DELTA_LATCH2_MODEM_CODEC); - err = platform_device_register(&ams_delta_modem_device); return err; diff --git a/arch/arm/mach-omap1/board-ams-delta.h b/arch/arm/mach-omap1/board-ams-delta.h index 1fbada29431a..a74a306d7e77 100644 --- a/arch/arm/mach-omap1/board-ams-delta.h +++ b/arch/arm/mach-omap1/board-ams-delta.h @@ -59,13 +59,6 @@ #define AMS_DELTA_LATCH2_GPIO_BASE AMS_DELTA_GPIO_PIN_LCD_VBLEN #define AMS_DELTA_LATCH2_NGPIO 16 -#ifndef __ASSEMBLY__ -void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value); -#define ams_delta_latch2_write(mask, value) \ - ams_delta_latch_write(AMS_DELTA_LATCH2_GPIO_BASE, \ - AMS_DELTA_LATCH2_NGPIO, (mask), (value)) -#endif - #endif /* CONFIG_MACH_AMS_DELTA */ #endif /* __ASM_ARCH_OMAP_AMS_DELTA_H */ -- 2.16.4