From patchwork Thu Jul 21 13:13:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Zhong X-Patchwork-Id: 9241659 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3CDEE60574 for ; Thu, 21 Jul 2016 13:15:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D06427E22 for ; Thu, 21 Jul 2016 13:15:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20AE327F46; Thu, 21 Jul 2016 13:15:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 198F827E22 for ; Thu, 21 Jul 2016 13:15:26 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bQDoz-0002Y7-HA; Thu, 21 Jul 2016 13:15:25 +0000 Received: from mail-pa0-f65.google.com ([209.85.220.65]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bQDok-00019o-NX for linux-rockchip@lists.infradead.org; Thu, 21 Jul 2016 13:15:11 +0000 Received: by mail-pa0-f65.google.com with SMTP id q2so5247767pap.0 for ; Thu, 21 Jul 2016 06:14:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yxT0cpunOjKAYi6jEHcyAmtivAr27gotdenDYXiOVb8=; b=aMfWPMYP308ZqhYM4npFgTOXBzJQSa2FOTPQr15sJOicdhClk8om0dZG9yT8wWLRTa LWsI0d1IkzMUthc+gLkobqjyRiVOSlw3vPT4DvUXTZuo/m9YquvpBg31mRpt7S0NqHCH Tr7dAA5xzC19RbuCmLWZHFlVICWo3JDQK30KVz9eyPj6UitqcGCG+WKvUDO1nLrvwA+/ pFOZqhcA2T+sFdov+eFQU5v52rbReZ9twOIoARfoBT2zpqPpdkNTxEzmHXEIYH4LbERH fDXvCueWqTiEFclgNWto7jJK650jDK1W5QPyJ0h/fSLDXFK08pl44iUFg7Pq48C2rIaL ah6w== X-Gm-Message-State: ALyK8tI+WyGDKfUGw12mkQyoH80hr2UdM4oVnXiIPy2Lf40wnj0dFV/bul5sCoO29smDCw== X-Received: by 10.66.134.20 with SMTP id pg20mr82479361pab.98.1469106889761; Thu, 21 Jul 2016 06:14:49 -0700 (PDT) Received: from localhost.localdomain ([103.29.142.67]) by smtp.gmail.com with ESMTPSA id q26sm12412685pfj.53.2016.07.21.06.14.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jul 2016 06:14:48 -0700 (PDT) From: Chris Zhong To: dianders@chromium.org, tfiga@chromium.org, heiko@sntech.de, yzq@rock-chips.com, groeck@chromium.org, myungjoo.ham@samsung.com, cw00.choi@samsung.com, wulf@rock-chips.com, marcheu@chromium.org Subject: [v6 PATCH 1/6] extcon: Add Type-C and DP support Date: Thu, 21 Jul 2016 21:13:23 +0800 Message-Id: <1469106808-28297-2-git-send-email-zyw@rock-chips.com> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1469106808-28297-1-git-send-email-zyw@rock-chips.com> References: <1469106808-28297-1-git-send-email-zyw@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160721_061510_878264_09976113 X-CRM114-Status: GOOD ( 12.45 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Zhong , linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add EXTCON_DISP_DP for the Display external connector. For Type-C connector the DisplayPort can work as an Alternate Mode(VESA DisplayPort Alt Mode on USB Type-C Standard). The Type-C support both normal and flipped orientation, so add a property to extcon. Signe-off-by: Chris Zhong Signed-off-by: Chris Zhong --- Changes in v6: - move the EXTCON_PROP_TYPEC_POLARITY to EXTCON_TYPE_USB in _supported Series-changes: 5 - support get property Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None Changes in v1: None drivers/extcon/extcon.c | 26 ++++++++++++++++++++++++++ include/linux/extcon.h | 13 +++++++++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index a1117db..f79b510 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -157,6 +157,11 @@ struct __extcon_info { .id = EXTCON_DISP_VGA, .name = "VGA", }, + [EXTCON_DISP_DP] = { + .type = EXTCON_TYPE_DISP | EXTCON_TYPE_USB, + .id = EXTCON_DISP_DP, + .name = "DP", + }, /* Miscellaneous external connector */ [EXTCON_DOCK] = { @@ -270,6 +275,7 @@ static bool is_extcon_property_supported(unsigned int id, switch (prop) { case EXTCON_PROP_USB_ID: case EXTCON_PROP_USB_VBUS: + case EXTCON_PROP_TYPEC_POLARITY: return true; default: break; @@ -547,6 +553,26 @@ int extcon_get_cable_property(struct extcon_dev *edev, unsigned int id, enum extcon_property prop, union extcon_property_value *val) { + struct extcon_cable *cable; + int index; + + if (!edev) + return -EINVAL; + + /* Check the property whether is supported or not */ + if (!is_extcon_property_supported(id, prop)) + return -EINVAL; + + /* Find the cable index of external connector by using id */ + index = find_cable_index_by_id(edev, id); + if (index < 0) + return index; + + /* Store the property value */ + cable = &edev->cables[index]; + + val->intval = cable->propval[prop].intval; + return 0; } diff --git a/include/linux/extcon.h b/include/linux/extcon.h index f6f0a8d..50ef87f 100644 --- a/include/linux/extcon.h +++ b/include/linux/extcon.h @@ -77,6 +77,7 @@ enum extcon_type { #define EXTCON_DISP_MHL 41 /* Mobile High-Definition Link */ #define EXTCON_DISP_DVI 42 /* Digital Visual Interface */ #define EXTCON_DISP_VGA 43 /* Video Graphics Array */ +#define EXTCON_DISP_DP 44 /* DisplayPort */ /* Miscellaneous external connector */ #define EXTCON_DOCK 60 @@ -108,9 +109,13 @@ enum extcon_property { * - EXTCON_PROP_USB_USB * @type: integer (int value) * @value: 0 (low) or 1 (high) + * - EXTCON_PROP_TYPEC_POLARITY, + * @type: integer (int value) + * @value: 0 (normal) or 1 (flip) */ EXTCON_PROP_USB_ID = 0, EXTCON_PROP_USB_VBUS, + EXTCON_PROP_TYPEC_POLARITY, /* Properties of EXTCON_TYPE_CHG. */ /* Properties of EXTCON_TYPE_JACK. */ @@ -225,6 +230,14 @@ extern int extcon_get_cable_state_(struct extcon_dev *edev, unsigned int id); extern int extcon_set_cable_state_(struct extcon_dev *edev, unsigned int id, bool cable_state); +extern int extcon_get_cable_property(struct extcon_dev *edev, unsigned int id, + enum extcon_property prop, + union extcon_property_value *val); + +extern int extcon_set_cable_property(struct extcon_dev *edev, unsigned int id, + enum extcon_property prop, + union extcon_property_value val); + /* * Following APIs are to monitor every action of a notifier. * Registrar gets notified for every external port of a connection device.