/* * Regulator driver for DA9063 PMIC series * * Copyright 2012 Dialog Semiconductors Ltd. * Copyright 2013 Philipp Zabel, Pengutronix * * Author: Krystian Garbaciak * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* Definition for registering regmap bit fields using a mask */ #define BFIELD(_reg, _mask) \ REG_FIELD(_reg, __builtin_ffs((int)_mask) - 1, \ sizeof(unsigned int) * 8 - __builtin_clz((_mask)) - 1) /* Regulator capabilities and registers description */ struct da9063_regulator_info { struct regulator_desc desc; /* Current limiting */ unsigned n_current_limits; const int *current_limits; /* DA9063 main register fields */ struct reg_field mode; /* buck mode of operation */ struct reg_field suspend; struct reg_field sleep; struct reg_field suspend_sleep; unsigned int suspend_vsel_reg; struct reg_field ilimit; /* DA9063 event detection bit */ struct reg_field oc_event; }; /* Macros for LDO */ #define DA9063_LDO(chip, regl_name, min_mV, step_mV, max_mV) \ .desc.id = chip##_ID_##regl_name, \ .desc.name = __stringify(chip##_##regl_name), \ .desc.ops = &da9063_ldo_ops, \ .desc.min_uV = (min_mV) * 1000, \ .desc.uV_step = (step_mV) * 1000, \ .desc.n_voltages = (((max_mV) - (min_mV))/(step_mV) + 1 \ + (DA9063_V##regl_name##_BIAS)), \ .desc.enable_reg = DA9063_REG_##regl_name##_CONT, \ .desc.enable_mask = DA9063_LDO_EN, \ .desc.vsel_reg = DA9063_REG_V##regl_name##_A, \ .desc.vsel_mask = DA9063_V##regl_name##_MASK, \ .desc.linear_min_sel = DA9063_V##regl_name##_BIAS, \ .sleep = BFIELD(DA9063_REG_V##regl_name##_A, DA9063_LDO_SL), \ .suspend_sleep = BFIELD(DA9063_REG_V##regl_name##_B, DA9063_LDO_SL), \ .suspend_vsel_reg = DA9063_REG_V##regl_name##_B /* Macros for voltage DC/DC converters (BUCKs) */ #define DA9063_BUCK(chip, regl_name, min_mV, step_mV, max_mV, limits_array) \ .desc.id = chip##_ID_##regl_name, \ .desc.name = __stringify(chip##_##regl_name), \ .desc.ops = &da9063_buck_ops, \ .desc.min_uV = (min_mV) * 1000, \ .desc.uV_step = (step_mV) * 1000, \ .desc.n_voltages = ((max_mV) - (min_mV))/(step_mV) + 1, \ .current_limits = limits_array, \ .n_current_limits = ARRAY_SIZE(limits_array) #define DA9063_BUCK_COMMON_FIELDS(regl_name) \ .desc.enable_reg = DA9063_REG_##regl_name##_CONT, \ .desc.enable_mask = DA9063_BUCK_EN, \ .desc.vsel_reg = DA9063_REG_V##regl_name##_A, \ .desc.vsel_mask = DA9063_VBUCK_MASK, \ .desc.linear_min_sel = DA9063_VBUCK_BIAS, \ .sleep = BFIELD(DA9063_REG_V##regl_name##_A, DA9063_BUCK_SL), \ .suspend_sleep = BFIELD(DA9063_REG_V##regl_name##_B, DA9063_BUCK_SL), \ .suspend_vsel_reg = DA9063_REG_V##regl_name##_B, \ .mode = BFIELD(DA9063_REG_##regl_name##_CFG, DA9063_BUCK_MODE_MASK) /* Defines asignment of regulators info table to chip model */ struct da9063_dev_model { const struct da9063_regulator_info *regulator_info; unsigned n_regulators; unsigned dev_model; }; /* Single regulator settings */ struct da9063_regulator { struct regulator_desc desc; struct regulator_dev *rdev; struct da9063 *hw; const struct da9063_regulator_info *info; struct regmap_field *mode; struct regmap_field *suspend; struct regmap_field *sleep; struct regmap_field *suspend_sleep; struct regmap_field *ilimit; }; /* Encapsulates all information for the regulators driver */ struct da9063_regulators { int irq_ldo_lim; int irq_uvov; unsigned n_regulators; /* Array size to be defined during init. Keep at end. */ struct da9063_regulator regulator[0]; }; /* BUCK modes for DA9063 */ enum { BUCK_MODE_MANUAL, /* 0 */ BUCK_MODE_SLEEP, /* 1 */ BUCK_MODE_SYNC, /* 2 */ BUCK_MODE_AUTO /* 3 */ }; /* Regulator operations */ /* Current limits array (in uA) for BCORE1, BCORE2, BPRO. Entry indexes corresponds to register values. */ static const int da9063_buck_a_limits[] = { 500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000, 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000 }; /* Current limits array (in uA) for BMEM, BIO, BPERI. Entry indexes corresponds to register values. */ static const int da9063_buck_b_limits[] = { 1500000, 1600000, 1700000, 1800000, 1900000, 2000000, 2100000, 2200000, 2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000 }; /* Current limits array (in uA) for merged BCORE1 and BCORE2. Entry indexes corresponds to register values. */ static const int da9063_bcores_merged_limits[] = { 1000000, 1200000, 1400000, 1600000, 1800000, 2000000, 2200000, 2400000, 2600000, 2800000, 3000000, 3200000, 3400000, 3600000, 3800000, 4000000 }; /* Current limits array (in uA) for merged BMEM and BIO. Entry indexes corresponds to register values. */ static const int da9063_bmem_bio_merged_limits[] = { 3000000, 3200000, 3400000, 3600000, 3800000, 4000000, 4200000, 4400000, 4600000, 4800000, 5000000, 5200000, 5400000, 5600000, 5800000, 6000000 }; static int da9063_set_current_limit(struct regulator_dev *rdev, int min_uA, int max_uA) { struct da9063_regulator *regl = rdev_get_drvdata(rdev); const struct da9063_regulator_info *rinfo = regl->info; int n, tval; for (n = 0; n < rinfo->n_current_limits; n++) { tval = rinfo->current_limits[n]; if (tval >= min_uA && tval <= max_uA) return regmap_field_write(regl->ilimit, n); } return -EINVAL; } static int da9063_get_current_limit(struct regulator_dev *rdev) { struct da9063_regulator *regl = rdev_get_drvdata(rdev); const struct da9063_regulator_info *rinfo = regl->info; unsigned int sel; int ret; ret = regmap_field_read(regl->ilimit, &sel); if (ret < 0) return ret; if (sel >= rinfo->n_current_limits) sel = rinfo->n_current_limits - 1; return rinfo->current_limits[sel]; } static int da9063_buck_set_mode(struct regulator_dev *rdev, unsigned mode) { struct da9063_regulator *regl = rdev_get_drvdata(rdev); unsigned val; switch (mode) { case REGULATOR_MODE_FAST: val = BUCK_MODE_SYNC; break; case REGULATOR_MODE_NORMAL: val = BUCK_MODE_AUTO; break; case REGULATOR_MODE_STANDBY: val = BUCK_MODE_SLEEP; break; default: return -EINVAL; } return regmap_field_write(regl->mode, val); } /* * Bucks use single mode register field for normal operation * and suspend state. * There are 3 modes to map to: FAST, NORMAL, and STANDBY. */ static unsigned da9063_buck_get_mode(struct regulator_dev *rdev) { struct da9063_regulator *regl = rdev_get_drvdata(rdev); struct regmap_field *field; unsigned int val, mode = 0; int ret; ret = regmap_field_read(regl->mode, &val); if (ret < 0) return ret; switch (val) { default: case BUCK_MODE_MANUAL: mode = REGU
.. This work is licensed under a Creative Commons Attribution 4.0 International
.. License.
.. http://creativecommons.org/licenses/by/4.0
.. (c) OPNFV, Huawei Technologies Co.,Ltd and others.

*************************************
Yardstick Test Case Description TC027
*************************************

.. _ipv6: https://wiki.opnfv.org/ipv6_opnfv_project

+-----------------------------------------------------------------------------+
|IPv6 connectivity between nodes on the tenant network                        |
|                                                                             |
+--------------+--------------------------------------------------------------+
|test case id  | OPNFV_YARDSTICK_TC027_IPv6 connectivity                      |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|metric        | RTT, Round Trip Time                                         |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|test purpose  | To do a basic verification that IPv6 connectivity is within  |
|              | acceptable boundaries when ipv6 packets travel between hosts |
|              | located on same or different compute blades.                 |
|              | The purpose is also to be able to spot trends. Test results, |
|              | graphs and similar shall be stored for comparison reasons and|
|              | product evolution understanding between different OPNFV      |
|              | versions and/or configurations.                              |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|configuration | file: opnfv_yardstick_tc027.yaml                             |
|              |                                                              |
|              | Packet size 56 bytes.                                        |
|              | SLA RTT is set to maximum 30 ms.                             |
|              | ipv6 test case can be configured as three independent modules|
|              | (setup, run, teardown). if you only want to setup ipv6       |
|              | testing environment, do some tests as you want, "run_step"   |
|              | of task yaml file should be configured as "setup". if you    |
|              | want to setup and run ping6 testing automatically, "run_step"|
|              | should be configured as "setup, run". and if you have had a  |
|              | environment which has been setup, you only wan to verify the |
|              | connectivity of ipv6 network, "run_step" should be "run". Of |
|              | course, default is that three modules run sequentially.      |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|test tool     | ping6                                                        |
|              |                                                              |
|              | Ping6 is normally part of Linux distribution, hence it       |
|              | doesn't need to be installed.                                |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|references    | ipv6_                                                        |
|              |                                                              |
|              | ETSI-NFV-TST001                                              |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|applicability | Test case can be configured with different run step          |
|              | you can run setup, run benchmark, teardown independently     |
|              | SLA is optional. The SLA in this test case serves as an      |
|              | example. Considerably lower RTT is expected.                 |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|pre-test      | The test case image needs to be installed into Glance        |
|conditions    | with ping6 included in it.                                   |
|              |                                                              |
|              | For Brahmaputra, a compass_os_nosdn_ha deploy scenario is    |
|              | need. more installer and more sdn deploy scenario will be    |
|              | supported soon                                               |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|test sequence | description and expected result                              |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|step 1        | To setup IPV6 testing environment:                           |
|              | 1. disable security group                                    |
|              | 2. create (ipv6, ipv4) router, network and subnet            |
|              | 3. create VRouter, VM1, VM2                                  |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|step 2        | To run ping6 to verify IPV6 connectivity :                   |
|              | 1. ssh to VM1                                                |
|              | 2. Ping6 to ipv6 router from VM1                             |
|              | 3. Get the result(RTT) and logs are stored                   |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|step 3        | To teardown IPV6 testing environment                         |
|              | 1. delete VRouter, VM1, VM2                                  |
|              | 2. delete (ipv6, ipv4) router, network and subnet            |
|              | 3. enable security group                                     |
|              |                                                              |
+--------------+--------------------------------------------------------------+
|test verdict  | Test should not PASS if any RTT is above the optional SLA    |
|              | value, or if there is a test case execution problem.         |
|              |                                                              |
+--------------+--------------------------------------------------------------+