From patchwork Sat May 7 06:21:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 9037681 Return-Path: X-Original-To: patchwork-platform-driver-x86@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EA5399F1D3 for ; Sat, 7 May 2016 06:21:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0683D203B1 for ; Sat, 7 May 2016 06:21:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ECE9C203AD for ; Sat, 7 May 2016 06:21:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752095AbcEGGVa (ORCPT ); Sat, 7 May 2016 02:21:30 -0400 Received: from ausxipps301.us.dell.com ([143.166.148.223]:13640 "EHLO ausxipps301.us.dell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750899AbcEGGVR (ORCPT ); Sat, 7 May 2016 02:21:17 -0400 DomainKey-Signature: s=smtpout; d=dell.com; c=nofws; q=dns; h=X-LoopCount0:X-IronPort-AV:From:To:Cc:Subject:Date: Message-Id:X-Mailer:In-Reply-To:References; b=RnbO03Da2E/llATE0d9//6Qo8ojgUKHOMjfVRuYLvln300Q3FxyTU17e rvDRzeKdTi2PYBVPy/NaJ/vU9b7AW8VukVu1sqG2mAeY+MPw6x86cDmBs Na1/25igSx3EYSBvptxLXrBzKuNL87I5qskSOY90GO0vK4pc02pW8ki3Q 4=; DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dell.com; i=@dell.com; q=dns/txt; s=smtpout; t=1462602077; x=1494138077; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=yrC0jSmzqQUVC4aOqwnKYOVz0RHJ/5Q1P+lZB5piUog=; b=aZ7GagmZQI1xKBBoMug6UIzVEBI3Ai61uS5CBEIRkFfvI/cXQS+6diZa AjucDbpcMk3xWLT2K4AgXriHlv880YdqfHRMRRnd9zEj4+e+OSNLZCZVg TAKPl2M77kbynS+l12VW+sjqJfK/XPxUofoTyj+d4D+t2Q2JKleNR3gFc w=; X-LoopCount0: from 10.209.151.17 X-IronPort-AV: E=Sophos;i="5.24,589,1454997600"; d="scan'208";a="790621734" From: Mario Limonciello To: dvhart@infradead.org Cc: LKML , platform-driver-x86@vger.kernel.org, Mario Limonciello Subject: [PATCH 2/2] dell-laptop: Expose auxiliary MAC address if available Date: Sat, 7 May 2016 01:21:02 -0500 Message-Id: <1462602062-32404-2-git-send-email-mario_limonciello@dell.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1462602062-32404-1-git-send-email-mario_limonciello@dell.com> References: <1462602062-32404-1-git-send-email-mario_limonciello@dell.com> Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 System with Type-C ports have a feature to expose an auxiliary persistent MAC address. This address is burned in at the factory. The intention of this address is to update the MAC address on Type-C docks containing an ethernet adapter to match the auxiliary address of the system connected to them. Signed-off-by: Mario Limonciello --- drivers/platform/x86/dell-laptop.c | 62 +++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/dell-laptop.c b/drivers/platform/x86/dell-laptop.c index 2c2f02b..f818ddf 100644 --- a/drivers/platform/x86/dell-laptop.c +++ b/drivers/platform/x86/dell-laptop.c @@ -87,6 +87,7 @@ static struct rfkill *wifi_rfkill; static struct rfkill *bluetooth_rfkill; static struct rfkill *wwan_rfkill; static bool force_rfkill; +static char *auxiliary_mac_address; module_param(force_rfkill, bool, 0444); MODULE_PARM_DESC(force_rfkill, "enable rfkill on non whitelisted models"); @@ -273,6 +274,58 @@ static const struct dmi_system_id dell_quirks[] __initconst = { { } }; +/* get_aux_mac + * returns the auxiliary mac address + * for assigning to a Type-C ethernet device + * such as that found in the Dell TB15 dock + */ +static int get_aux_mac(void) +{ + struct calling_interface_buffer *buffer; + int ret; + unsigned char *address = + (unsigned char *) __get_free_page(GFP_KERNEL | GFP_DMA32); + + buffer = dell_smbios_get_buffer(); + + /* prepare a 17 byte buffer */ + dell_smbios_prepare_v2_call(address, 17); + buffer->input[0] = virt_to_phys(address); + dell_smbios_send_request(11, 6); + ret = buffer->output[0]; + + if (ret != 0) + goto auxout; + + dell_smbios_clear_buffer(); + + /* address will be stored in byte 4-> */ + auxiliary_mac_address = kmalloc(13, GFP_KERNEL); + memcpy(auxiliary_mac_address, &address[4], 13); + + auxout: + free_page((unsigned long)address); + dell_smbios_release_buffer(); + return dell_smbios_error(ret); + +} + +static ssize_t auxiliary_mac_show(struct device *dev, + struct device_attribute *attr, char *page) +{ + return sprintf(page, "%s\n", auxiliary_mac_address); +} + +static DEVICE_ATTR_RO(auxiliary_mac); +static struct attribute *dell_attributes[] = { + &dev_attr_auxiliary_mac.attr, + NULL +}; +static const struct attribute_group dell_attr_group = { +.attrs = dell_attributes, +}; + + /* * Derived from information in smbios-wireless-ctl: * @@ -392,7 +445,6 @@ static const struct dmi_system_id dell_quirks[] __initconst = { * cbArg1, byte0 = 0x13 * cbRes1 Standard return codes (0, -1, -2) */ - static int dell_rfkill_set(void *data, bool blocked) { struct calling_interface_buffer *buffer; @@ -2003,6 +2055,12 @@ static int __init dell_init(void) goto fail_rfkill; } + ret = get_aux_mac(); + if (!ret) { + sysfs_create_group(&platform_device->dev.kobj, + &dell_attr_group); + } + if (quirks && quirks->touchpad_led) touchpad_led_init(&platform_device->dev); @@ -2048,6 +2106,7 @@ static int __init dell_init(void) backlight_update_status(dell_backlight_device); } + return 0; fail_backlight: @@ -2064,6 +2123,7 @@ fail_platform_driver: static void __exit dell_exit(void) { + kfree(auxiliary_mac_address); debugfs_remove_recursive(dell_laptop_dir); if (quirks && quirks->touchpad_led) touchpad_led_exit();