From patchwork Fri Nov 27 09:28:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 63302 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAR9XVXo005173 for ; Fri, 27 Nov 2009 09:33:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753142AbZK0JdY (ORCPT ); Fri, 27 Nov 2009 04:33:24 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754176AbZK0JdX (ORCPT ); Fri, 27 Nov 2009 04:33:23 -0500 Received: from mail-yx0-f188.google.com ([209.85.210.188]:39055 "EHLO mail-yx0-f188.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753142AbZK0JdW (ORCPT ); Fri, 27 Nov 2009 04:33:22 -0500 Received: by yxe26 with SMTP id 26so1195552yxe.4 for ; Fri, 27 Nov 2009 01:33:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :subject; bh=8p5KkMnVgKad+b8QLpU/gFr87wGkjREWd4p8DfBaFRE=; b=tgx+F1RJeBerkuH39HnAXdfrB3Rq9V6ZYJBMQZ1U8+bIXFynPsPheUG8jB85e4aEyc 8MX+PdPU2AS7GxSVp/CRsiEhv1++0B3vAwpiSrtaDCATflUKYonWnIm1ONGMBFPa04lU dhuSgWGuV/kEp5bEQLPHkr1ZcSQLSoHzufHWE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:subject; b=ApPTJjZq5gFAaK8KjUQy5rasHWTc+PyaFZf0pyjnck87aNkF9Tf47p+aPCs1j9Jimn sUDjkQXJ3T+Yfxi8/rLgE+xZGIZrVVOTtn9skms2uUKfQNi0G0q1czrRuWEAQGMceae8 e9E3cUU858hYKm+ZOcMkGx34hh9qxdSj+fSoo= Received: by 10.101.200.29 with SMTP id c29mr169908anq.101.1259314408990; Fri, 27 Nov 2009 01:33:28 -0800 (PST) Received: from rxone.opensource.se (49.14.32.202.bf.2iij.net [202.32.14.49]) by mx.google.com with ESMTPS id 23sm750876yxe.0.2009.11.27.01.33.27 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 27 Nov 2009 01:33:28 -0800 (PST) From: Magnus Damm To: linux-sh@vger.kernel.org Cc: Magnus Damm , lethal@linux-sh.org Date: Fri, 27 Nov 2009 18:28:03 +0900 Message-Id: <20091127092803.9204.29222.sendpatchset@rxone.opensource.se> Subject: [PATCH] sh: Improve kfr2r09 serial port setup code Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org --- 0008/arch/sh/boards/mach-kfr2r09/setup.c +++ work/arch/sh/boards/mach-kfr2r09/setup.c 2009-11-27 18:13:11.000000000 +0900 @@ -414,11 +414,59 @@ static int kfr2r09_usb0_gadget_i2c_setup return 0; } + +static int kfr2r09_serial_i2c_setup(void) +{ + struct i2c_adapter *a; + struct i2c_msg msg; + unsigned char buf[2]; + int ret; + + a = i2c_get_adapter(0); + if (!a) + return -ENODEV; + + /* set bit 6 (the 7th bit) of chip at 0x09, register 0x13 */ + buf[0] = 0x13; + msg.addr = 0x09; + msg.buf = buf; + msg.len = 1; + msg.flags = 0; + ret = i2c_transfer(a, &msg, 1); + if (ret != 1) + return -ENODEV; + + buf[0] = 0; + msg.addr = 0x09; + msg.buf = buf; + msg.len = 1; + msg.flags = I2C_M_RD; + ret = i2c_transfer(a, &msg, 1); + if (ret != 1) + return -ENODEV; + + buf[1] = buf[0] | (1 << 6); + buf[0] = 0x13; + msg.addr = 0x09; + msg.buf = buf; + msg.len = 2; + msg.flags = 0; + ret = i2c_transfer(a, &msg, 1); + if (ret != 1) + return -ENODEV; + + return 0; +} #else static int kfr2r09_usb0_gadget_i2c_setup(void) { return -ENODEV; } + +static int kfr2r09_serial_i2c_setup(void) +{ + return -ENODEV; +} #endif static int kfr2r09_usb0_gadget_setup(void) @@ -463,6 +511,9 @@ static int __init kfr2r09_devices_setup( /* enable SCIF1 serial port for YC401 console support */ gpio_request(GPIO_FN_SCIF1_RXD, NULL); gpio_request(GPIO_FN_SCIF1_TXD, NULL); + kfr2r09_serial_i2c_setup(); /* ECONTMSK(bit6=L10ONEN) set 1 */ + gpio_request(GPIO_PTG3, NULL); /* HPON_ON */ + gpio_direction_output(GPIO_PTG3, 1); /* HPON_ON = H */ /* setup NOR flash at CS0 */ ctrl_outl(0x36db0400, BSC_CS0BCR);