From patchwork Thu May 29 13:17:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 4264271 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 86CC49F1E7 for ; Thu, 29 May 2014 13:16:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0040A20171 for ; Thu, 29 May 2014 13:16:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 066F520170 for ; Thu, 29 May 2014 13:16:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932625AbaE2NPe (ORCPT ); Thu, 29 May 2014 09:15:34 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:47271 "EHLO mail-pb0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932081AbaE2NPc (ORCPT ); Thu, 29 May 2014 09:15:32 -0400 Received: by mail-pb0-f45.google.com with SMTP id um1so358077pbc.18 for ; Thu, 29 May 2014 06:15:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:date:message-id:in-reply-to:references:subject; bh=WmL9e/9moGi0OCraNVehUu2ISI/7jz2GBrMKcqz9//8=; b=Euarq38UOaCKXCvwZxGCSw+s+VckjKMnm761ZD5mZhciWPLnfx24NOhhyf6iJT8J1M vd9nfgve10lvz0Lfjdw8Ihz/Vj/l5qcoViZRe8fkYYR73zZpmjO9XhImb8VLOv5s1y0w LK0Mu5eNVFjU3u7UT/xE/lvyP3xUbK+94rjfCpQT66GEMR4k7xc2ByR4cOJZS3JeWQYa JclF0UchiHiBpCNcZlZYwCTOk9ClooYvHrIrlLfMRIsWGQRiguk2gngj+FrYboTH8CKZ +CXMz7z8G9oI/2sNEGvJ99OYb++pgq+v+mizuw0LohZ7TG4XQOZcRBWmiPx06DsFtriz enQQ== X-Received: by 10.68.194.134 with SMTP id hw6mr8772171pbc.49.1401369331383; Thu, 29 May 2014 06:15:31 -0700 (PDT) Received: from [127.0.0.1] (s214090.ppp.asahi-net.or.jp. [220.157.214.90]) by mx.google.com with ESMTPSA id jd5sm1274925pbb.18.2014.05.29.06.15.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 May 2014 06:15:30 -0700 (PDT) From: Magnus Damm To: linux-kernel@vger.kernel.org Cc: devel@driverdev.osuosl.org, linux-sh@vger.kernel.org, gregkh@linuxfoundation.org, horms@verge.net.au, geert@linux-m68k.org, laurent.pinchart@ideasonboard.com, olof@lixom.net, Magnus Damm , dan.carpenter@oracle.com Date: Thu, 29 May 2014 22:17:32 +0900 Message-Id: <20140529131732.2329.50630.sendpatchset@w520> In-Reply-To: <20140529131650.2329.3197.sendpatchset@w520> References: <20140529131650.2329.3197.sendpatchset@w520> Subject: [PATCH v2 04/05] staging: board: Initial board staging support Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Magnus Damm Add staging board base support to allow continuous upstream in-tree development and integration of platform devices. Helps developers integrate devices as platform devices for device drivers that only provide platform device bindings. This in turn allows for incremental development of both hardware feature support and DT binding work in parallel. Two separate pieces of board staging functionality is provided to ease per-board staging board support: - The board_staging() macro allows easy per-board callbacks - The board_staging_dt_node_available() provides DT node checking Tested on the KZM9D board with the emxx_udc staging driver. Signed-off-by: Magnus Damm --- Changes since V1: - New broken out staging board base support - Added the function board_staging_dt_node_available() - Added a TODO file drivers/staging/Kconfig | 2 + drivers/staging/Makefile | 1 drivers/staging/board/Kconfig | 7 ++++++ drivers/staging/board/Makefile | 1 drivers/staging/board/TODO | 2 + drivers/staging/board/board.c | 41 ++++++++++++++++++++++++++++++++++++++++ drivers/staging/board/board.h | 20 +++++++++++++++++++ 7 files changed, 74 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 0008/drivers/staging/Kconfig +++ work/drivers/staging/Kconfig 2014-05-29 21:40:40.000000000 +0900 @@ -112,6 +112,8 @@ source "drivers/staging/media/Kconfig" source "drivers/staging/android/Kconfig" +source "drivers/staging/board/Kconfig" + source "drivers/staging/ozwpan/Kconfig" source "drivers/staging/gdm72xx/Kconfig" --- 0008/drivers/staging/Makefile +++ work/drivers/staging/Makefile 2014-05-29 21:40:40.000000000 +0900 @@ -49,6 +49,7 @@ obj-$(CONFIG_TOUCHSCREEN_CLEARPAD_TM1217 obj-$(CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI4) += ste_rmi4/ obj-$(CONFIG_MFD_NVEC) += nvec/ obj-$(CONFIG_ANDROID) += android/ +obj-$(CONFIG_STAGING_BOARD) += board/ obj-$(CONFIG_USB_WPAN_HCD) += ozwpan/ obj-$(CONFIG_WIMAX_GDM72XX) += gdm72xx/ obj-$(CONFIG_LTE_GDM724X) += gdm724x/ --- /dev/null +++ work/drivers/staging/board/Kconfig 2014-05-29 21:40:41.000000000 +0900 @@ -0,0 +1,7 @@ +config STAGING_BOARD + boolean "Staging Board Support" + help + Select to enable per-board staging support code. + + If in doubt, say N here. + --- /dev/null +++ work/drivers/staging/board/Makefile 2014-05-29 21:40:41.000000000 +0900 @@ -0,0 +1 @@ +obj-y := board.o --- /dev/null +++ work/drivers/staging/board/TODO 2014-05-29 21:40:41.000000000 +0900 @@ -0,0 +1,2 @@ +* replace platform device code with DT nodes once the driver supports DT +* remove staging board code when no more platform devices are needed --- /dev/null +++ work/drivers/staging/board/board.c 2014-05-29 21:46:32.000000000 +0900 @@ -0,0 +1,41 @@ +#include +#include +#include +#include +#include +#include "board.h" + +static bool find_by_address(u64 base_address) +{ + struct device_node *dn = of_find_all_nodes(NULL); + struct resource res; + + while (dn) { + if (of_can_translate_address(dn) + && !of_address_to_resource(dn, 0, &res)) { + if (res.start == base_address) { + of_node_put(dn); + return true; + } + } + dn = of_find_all_nodes(dn); + } + + return false; +} + +bool __init board_staging_dt_node_available(const struct resource *resource, + unsigned int num_resources) +{ + unsigned int i; + + for (i = 0; i < num_resources; i++) { + const struct resource *r = resource + i; + + if (resource_type(r) == IORESOURCE_MEM) + if (find_by_address(r->start)) + return true; /* DT node available */ + } + + return false; /* Nothing found */ +} --- /dev/null +++ work/drivers/staging/board/board.h 2014-05-29 21:40:41.000000000 +0900 @@ -0,0 +1,20 @@ +#ifndef __BOARD_H__ +#define __BOARD_H__ +#include +#include + +bool board_staging_dt_node_available(const struct resource *resource, + unsigned int num_resources); + +#define board_staging(str, fn) \ +static int __init runtime_board_check(void) \ +{ \ + if (of_machine_is_compatible(str)) \ + fn(); \ + \ + return 0; \ +} \ + \ +late_initcall(runtime_board_check) + +#endif /* __BOARD_H__ */