From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5494C433E0 for ; Thu, 25 Jun 2020 13:34:22 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A716020781 for ; Thu, 25 Jun 2020 13:34:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A716020781 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0F4416E1B9; Thu, 25 Jun 2020 13:34:22 +0000 (UTC) Received: from mail-ot1-f67.google.com (mail-ot1-f67.google.com [209.85.210.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id 728B06E1B9 for ; Thu, 25 Jun 2020 13:34:20 +0000 (UTC) Received: by mail-ot1-f67.google.com with SMTP id 72so5253120otc.3 for ; Thu, 25 Jun 2020 06:34:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TRchS3u19fiIS7C0UK/+ytBsjjoblV6gX2Npu5INAM4=; b=ZjPSXBh0Heou547AjT0Hd/0/TZFJAOFL4eq46W7z2DD1BX9ZoFwRhX8cS1BJcqQC3c IrnFM72dtxUrBcKNP01LAhOW/Tq7zmbZZZ+bOkNF3Hd2wyQpnNOTfVYLCYVR8YHLPsAz 5lOC6YwrxX8rTBN2Svtdgs9SGbGh50alckAjVJBZRNRvoXAKI4kWQhE57ZmQHjBY9gyB sp9mOaJZwQ3a4Lia8XXUqPZajQtwq8GXP4McwsUXT7IEhe8sMnJzg0HMRW3gHIrD6uw0 JS+bDBhshz0fBTaR7YCfUAFQD8f9GfA3g5XOrGqGOARIRmowY1089Taq/wr01z1eWFi+ 2N+g== X-Gm-Message-State: AOAM533QlVRTyyaFoLbDR8p7ACXdWUNaPjYls92L/Dg9tSg+uIQs/QjM h4ML+E7L26llC5CppdYCs2OGQ2xNnqYNnkjNOEY= X-Google-Smtp-Source: ABdhPJyfZs5wkrSbKwnWnBwMiohr7YRapQqDrIV04olBcp+FF+AgnfXQu95DtWEricaRj/rfIg0LDIgDkjjgL35xt9c= X-Received: by 2002:a05:6830:10d6:: with SMTP id z22mr6642778oto.250.1593092059705; Thu, 25 Jun 2020 06:34:19 -0700 (PDT) MIME-Version: 1.0 References: <20200625120011.16168-1-tzimmermann@suse.de> <20200625120011.16168-7-tzimmermann@suse.de> In-Reply-To: <20200625120011.16168-7-tzimmermann@suse.de> From: Geert Uytterhoeven Date: Thu, 25 Jun 2020 15:34:05 +0200 Message-ID: Subject: Re: [PATCH 6/9] drm/simplekms: Acquire clocks from DT device node To: Thomas Zimmermann X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Geert Uytterhoeven , David Airlie , Emil Velikov , DRI Development , Liam Girdwood , Hans de Goede , Mark Brown , Gerd Hoffmann , Sam Ravnborg Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Thomas, On Thu, Jun 25, 2020 at 2:00 PM Thomas Zimmermann wrote: > Make sure required hardware clocks are enabled while the firmware > framebuffer is in use. > > The basic code has been taken from the simplefb driver and adapted > to DRM. Clocks are released automatically via devres helpers. > > Signed-off-by: Thomas Zimmermann Thanks for your patch! > --- a/drivers/gpu/drm/tiny/simplekms.c > +++ b/drivers/gpu/drm/tiny/simplekms.c > @@ -210,6 +218,103 @@ static struct simplekms_device *simplekms_device_of_dev(struct drm_device *dev) > return container_of(dev, struct simplekms_device, dev); > } > > +/* > + * Hardware > + */ > + > +#if defined CONFIG_OF && defined CONFIG_COMMON_CLK > +/* > + * Clock handling code. > + * > + * Here we handle the clocks property of our "simple-framebuffer" dt node. > + * This is necessary so that we can make sure that any clocks needed by > + * the display engine that the bootloader set up for us (and for which it > + * provided a simplefb dt node), stay up, for the life of the simplefb > + * driver. > + * > + * When the driver unloads, we cleanly disable, and then release the clocks. > + * > + * We only complain about errors here, no action is taken as the most likely > + * error can only happen due to a mismatch between the bootloader which set > + * up simplefb, and the clock definitions in the device tree. Chances are > + * that there are no adverse effects, and if there are, a clean teardown of > + * the fb probe will not help us much either. So just complain and carry on, > + * and hope that the user actually gets a working fb at the end of things. > + */ > + > +static void simplekms_device_release_clocks(void *res) > +{ > + struct simplekms_device *sdev = simplekms_device_of_dev(res); > + unsigned int i; > + > + for (i = 0; i < sdev->clk_count; ++i) { > + if (sdev->clks[i]) { > + clk_disable_unprepare(sdev->clks[i]); > + clk_put(sdev->clks[i]); > + } > + } > +} > + > +static int simplekms_device_init_clocks(struct simplekms_device *sdev) > +{ > + struct drm_device *dev = &sdev->dev; > + struct platform_device *pdev = sdev->pdev; > + struct device_node *of_node = pdev->dev.of_node; > + struct clk *clock; > + unsigned int i; > + int ret; > + > + if (dev_get_platdata(&pdev->dev) || !of_node) > + return 0; > + > + sdev->clk_count = of_clk_get_parent_count(of_node); > + if (!sdev->clk_count) > + return 0; > + > + sdev->clks = drmm_kzalloc(dev, sdev->clk_count * sizeof(sdev->clks[0]), > + GFP_KERNEL); > + if (!sdev->clks) > + return -ENOMEM; > + > + for (i = 0; i < sdev->clk_count; ++i) { > + clock = of_clk_get(of_node, i); clk_bulk_get_all()? Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel