/* * drivers/leds/leds-mlxcpld.c * Copyright (c) 2016 Mellanox Technologies. All rights reserved. * Copyright (c) 2016 Vadim Pasternak <vadimp@mellanox.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the names of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE.
*/
/** * struct mlxcpld_param - LED access parameters: * @offset: offset for LED access in CPLD device * @mask: mask for LED access in CPLD device * @base_color: base color code for LED
**/ struct mlxcpld_param {
u8 offset;
u8 mask;
u8 base_color;
};
/** * struct mlxcpld_led_priv - LED private data: * @cdev: LED class device instance * @param: LED CPLD access parameters
**/ struct mlxcpld_led_priv { struct led_classdev cdev; struct mlxcpld_param param;
};
/** * struct mlxcpld_led_profile - system LED profile (defined per system class): * @offset: offset for LED access in CPLD device * @mask: mask for LED access in CPLD device * @base_color: base color code * @brightness: default brightness setting (on/off) * @name: LED name
**/ struct mlxcpld_led_profile {
u8 offset;
u8 mask;
u8 base_color; enum led_brightness brightness; constchar *name;
};
/** * struct mlxcpld_led_pdata - system LED private data * @pdev: platform device pointer * @pled: LED class device instance * @profile: system configuration profile * @num_led_instances: number of LED instances * @lock: device access lock
**/ struct mlxcpld_led_pdata { struct platform_device *pdev; struct mlxcpld_led_priv *pled; struct mlxcpld_led_profile *profile; int num_led_instances;
spinlock_t lock;
};
/* * Each LED is controlled through low or high nibble of the relevant * CPLD register. Register offset is specified by off parameter. * Parameter vset provides color code: 0x0 for off, 0x5 for solid red, * 0x6 for 3Hz blink red, 0xd for solid green, 0xe for 3Hz blink * green. * Parameter mask specifies which nibble is used for specific LED: mask * 0xf0 - lower nibble is to be used (bits from 0 to 3), mask 0x0f - * higher nibble (bits from 4 to 7).
*/
spin_lock(&mlxcpld_led->lock);
mlxcpld_led_bus_access_func(MLXPLAT_CPLD_LPC_REG_BASE_ADRR, off, 1,
&val);
nib = (mask == 0xf0) ? vset : (vset << 4);
val = (val & mask) | nib;
mlxcpld_led_bus_access_func(MLXPLAT_CPLD_LPC_REG_BASE_ADRR, off, 0,
&val);
spin_unlock(&mlxcpld_led->lock);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.