Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp650074ybm; Thu, 28 May 2020 11:39:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwREChmsUGM+zMSHzdelWjHgWf9K9BflPP7e46lmbu5IOG0l6+2E4YXSC2T9hR3pGwhL0qu X-Received: by 2002:a17:906:f44:: with SMTP id h4mr4334750ejj.38.1590691143821; Thu, 28 May 2020 11:39:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590691143; cv=none; d=google.com; s=arc-20160816; b=Bfr++U9dIXsS1ui4GsIuWwRL6AUbUpZU0auNlssNumlXFS2pOPxmWYKuYHJrw7J1P+ vmKZ2Eu01HhOErCRE21eLOxjv8XTezS7ABRebLMG7A/SbSKKeWAu1BUy8eqjyc23I5J7 ZCkaWjTWLCz9TN6DGRXemXOf0jqknj3Ws05dlTZ+r7koFh5LopWoLG8Gg+EUKVHyZZQg nTY4h6VTVm8T2IsiMMZDQQYOE6ZI6tgsLem/4tdECIfnu2sV/TL6ajJ+2+o2Ns4pBI+u Sjz9fCalNCf90UBv+tN5AbvvtLv/rABL3McVYku/VohBiE7SPeu1bxoFV5d5ChfGYQWF ZTQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:content-transfer-encoding :mime-version:subject:from:references:in-reply-to:message-id:date :dkim-signature; bh=UyNzEZwkZfxCsnkVcoe9SbSwiL/VgYqzZ0s/LhSmTL8=; b=0b/bnfrJE0dFlTlCmavPwVN6vFr7cHnJECoupjmYiTEH9AseqAN3YUXmsJ6t+Lneak Z04WqSwwINjZt8szXpEouCibpPmsApnDsni2//PEKmipkUHao8MXdCKyWG+ALqKyVwr+ rkV6Kpbg2erIZgC/3xbvKEY4guXHi6uhGIeT+j+XhaoQF6kNgZjf2Ki09bw4inY/4CFF 0rtWclGAnKZCf3KRU9fvmD10931tFKUqs+iJkEtrlCzOBCXbJXAcK77o8yb8naadrfKo XjEcFjikwbB8NPFAe1STQffFWuUM1Y3a8uDAISluqxqFbg0EjYxnC8G8+A9LR4gxxayy 8amQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=mjOQBr4a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qq21si4257771ejb.752.2020.05.28.11.38.40; Thu, 28 May 2020 11:39:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=mjOQBr4a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405916AbgE1SgK (ORCPT + 99 others); Thu, 28 May 2020 14:36:10 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:42498 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405891AbgE1Sf4 (ORCPT ); Thu, 28 May 2020 14:35:56 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 49XxGf65JDzBn; Thu, 28 May 2020 20:35:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1590690954; bh=QjngVfF3jGFX7hjsYC0+ki+GV1G3GFLfuWLY+mPbiy8=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=mjOQBr4a0z6i6cI5tKBgwyT5sDSr+t668gVJneiKtoM8WU27fbdcalb43S5QkFoJ5 idpS8+XgQIXeIK0cX+uBp3z6rbvLhe2Q7xmL+nGTh9CEAqIFHasXlJ2ai4yQQBwFtN A2GuVMXuhg6g7lCM081DGpeCJjH2TFsWkkOJKQ6Oh1EHb95Wz4Dq9Z1QrqETuIOsv/ XuwG9FZ9vNw0TDieZibrq989ipD0ypwzy9orWcSQEJwK52S18WVKTFhlf8FPP8CS4T MAjH6iuiD8WurIhd/K8NBHsnm82furj3JTSieDPiRGzBlua33OwlyM3ULgUTjIm84+ TlQAc1yXCB/SA== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Thu, 28 May 2020 20:35:54 +0200 Message-Id: In-Reply-To: References: From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH 3/3] usb: gadget: udc: atmel: implement .pullup callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: Cristian Birsan , Felipe Balbi , Greg Kroah-Hartman , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , Songjun Wu Cc: linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement udc->pullup callback, so that udc_connect/disconnect work. This is needed for composite gadget, as it assumes udc_disconnect() actually works and calls gadget's ->disconnect callback. Signed-off-by: Michał Mirosław --- drivers/usb/gadget/udc/atmel_usba_udc.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index 9342a3d24963..c5128c229c52 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c @@ -1028,6 +1028,7 @@ usba_udc_set_selfpowered(struct usb_gadget *gadget, int is_selfpowered) return 0; } +static int atmel_usba_pullup(struct usb_gadget *gadget, int is_on); static int atmel_usba_start(struct usb_gadget *gadget, struct usb_gadget_driver *driver); static int atmel_usba_stop(struct usb_gadget *gadget); @@ -1101,6 +1102,7 @@ static const struct usb_gadget_ops usba_udc_ops = { .get_frame = usba_udc_get_frame, .wakeup = usba_udc_wakeup, .set_selfpowered = usba_udc_set_selfpowered, + .pullup = atmel_usba_pullup, .udc_start = atmel_usba_start, .udc_stop = atmel_usba_stop, .match_ep = atmel_usba_match_ep, @@ -1957,6 +1959,24 @@ static irqreturn_t usba_vbus_irq_thread(int irq, void *devid) return IRQ_HANDLED; } +static int atmel_usba_pullup(struct usb_gadget *gadget, int is_on) +{ + struct usba_udc *udc = container_of(gadget, struct usba_udc, gadget); + unsigned long flags; + u32 ctrl; + + spin_lock_irqsave(&udc->lock, flags); + ctrl = usba_readl(udc, CTRL); + if (is_on) + ctrl &= ~USBA_DETACH; + else + ctrl |= USBA_DETACH; + usba_writel(udc, CTRL, ctrl); + spin_unlock_irqrestore(&udc->lock, flags); + + return 0; +} + static int atmel_usba_start(struct usb_gadget *gadget, struct usb_gadget_driver *driver) { -- 2.20.1