/* * iio/adc/ad799x.c * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc. * * based on iio/adc/max1363 * Copyright (C) 2008-2010 Jonathan Cameron * * based on linux/drivers/i2c/chips/max123x * Copyright (C) 2002-2004 Stefan Eletzhofer * * based on linux/drivers/acron/char/pcf8583.c * Copyright (C) 2000 Russell King * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * ad799x.c * * Support for ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, * ad7998 and similar chips. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define AD799X_CHANNEL_SHIFT 4 /* * AD7991, AD7995 and AD7999 defines */ #define AD7991_REF_SEL 0x08 #define AD7991_FLTR 0x04 #define AD7991_BIT_TRIAL_DELAY 0x02 #define AD7991_SAMPLE_DELAY 0x01 /* * AD7992, AD7993, AD7994, AD7997 and AD7998 defines */ #define AD7998_FLTR BIT(3) #define AD7998_ALERT_EN BIT(2) #define AD7998_BUSY_ALERT BIT(1) #define AD7998_BUSY_ALERT_POL BIT(0) #define AD7998_CONV_RES_REG 0x0 #define AD7998_ALERT_STAT_REG 0x1 #define AD7998_CONF_REG 0x2 #define AD7998_CYCLE_TMR_REG 0x3 #define AD7998_DATALOW_REG(x) ((x) * 3 + 0x4) #define AD7998_DATAHIGH_REG(x) ((x) * 3 + 0x5) #define AD7998_HYST_REG(x) ((x) * 3 + 0x6) #define AD7998_CYC_MASK GENMASK(2, 0) #define AD7998_CYC_DIS 0x0 #define AD7998_CYC_TCONF_32 0x1 #define AD7998_CYC_TCONF_64 0x2 #define AD7998_CYC_TCONF_128 0x3 #define AD7998_CYC_TCONF_256 0x4 #define AD7998_CYC_TCONF_512 0x5 #define AD7998_CYC_TCONF_1024 0x6 #define AD7998_CYC_TCONF_2048 0x7 #define AD7998_ALERT_STAT_CLEAR 0xFF /* * AD7997 and AD7997 defines */ #define AD7997_8_READ_SINGLE BIT(7) #define AD7997_8_READ_SEQUENCE (BIT(6) | BIT(5) | BIT(4)) enum { ad7991, ad7995, ad7999, ad7992, ad7993, ad7994, ad7997, ad7998 }; /** * struct ad799x_chip_config - chip specific information * @channel: channel specification * @default_config: device default configuration * @info: pointer to iio_info struct */ struct ad799x_chip_config { const struct iio_chan_spec channel[9]; u16 default_config; const struct iio_info *info; }; /** * struct ad799x_chip_info - chip specific information * @num_channels: number of channels * @noirq_config: device configuration w/o IRQ * @irq_config: device configuration w/IRQ */ struct ad799x_chip_info { int num_channels; const struct ad799x_chip_config noirq_config; const struct ad799x_chip_config irq_config; }; struct ad799x_state { struct i2c_client *client; const struct ad799x_chip_config *chip_config; struct regulator *reg; struct regulator *vref; unsigned id; u16 config; u8 *rx_buf; unsigned int transfer_size; }; static int ad799x_write_config(struct ad799x_state *st, u16 val) { switch (st->id) { case ad7997: case ad7998: return i2c_smbus_write_word_swapped(st->client, AD7998_CONF_REG, val); case ad7992: case ad7993: case ad7994: return i2c_smbus_write_byte_data(st->client, AD7998_CONF_REG, val); default: /* Will be written when doing a conversion */ st->config = val; return 0; } } static int ad799x_read_config(struct ad799x_state *st) { switch (st->id) { case ad7997: case ad7998: return i2c_smbus_read_word_swapped(st->client, AD7998_CONF_REG); case ad7992: case ad7993: case ad7994: return i2c_smbus_read_byte_data(st->client, AD7998_CONF_REG); default: /* No readback support */ return st->config; } } /** * ad799x_trigger_handler() bh of trigger launched polling to ring buffer * * Currently there is no option in this driver to disable the saving of * timestamps within the ring. **/ static irqreturn_t ad799x_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct ad799x_state *st = iio_priv(indio_dev); int b_sent; u8 cmd; switch (st->id) { case ad7991: case ad7995: case ad7999: cmd = st->config | (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT); break; case ad7992: case ad7993: case ad7994: cmd = (*indio_dev->active_scan_mask << AD799X_CHANNEL_SHIFT) | AD7998_CONV_RES_REG; break; case ad7997: case ad7998: cmd = AD7997_8_READ_SEQUENCE | AD7998_CONV_RES_REG; break; default: cmd = 0; } b_sent = i2c_smbus_read_i2c_block_data(st->client, cmd, st->transfer_size, st->rx_buf); if (b_sent < 0) goto out; iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf, iio_get_time_ns()); out: iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; } static int ad799x_update_scan_mode(struct iio_dev *indio_dev, const unsigned long *scan_mask) { struct ad799x_state *st = iio_priv(indio_dev); kfree(st->rx_buf); st->rx_buf = kmalloc(indio_dev->scan_bytes, GFP_KERNEL); if (!st-
##############################################################################
# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
---
# Sample benchmark task config file
# measure storage and file system performance using bonnie++

schema: "yardstick:task:0.1"

{% set provider = provider or none %}
{% set physical_network = physical_network or 'physnet1' %}
{% set segmentation_id = segmentation_id or none %}

scenarios:
-
  type: Bonnie++
  options:
    file_size: 1024
    ram_size: 512
    test_dir: /tmp
    #test_user: root
    concurrency: 1

  host: bonnie.demo

  runner:
    type: Iteration
    iterations: 1

context:
  name: demo
  image: yardstick-image
  flavor: yardstick-flavor
  user: ubuntu

  servers:
    bonnie:
      floating_ip: true

  networks:
    test:
      cidr: '10.0.1.0/24'
      {% if provider == "vlan" %}
      provider: {{provider}}
      physical_network: {{physical_network}}
        {% if segmentation_id %}
      segmentation_id: {{segmentation_id}}
        {% endif %}
      {% endif %}
est_threaded_irq(&client->dev, client->irq, NULL, ad799x_event_handler, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, client->name, indio_dev); if (ret) goto error_cleanup_ring; } ret = iio_device_register(indio_dev); if (ret) goto error_cleanup_ring; return 0; error_cleanup_ring: iio_triggered_buffer_cleanup(indio_dev); error_disable_vref: regulator_disable(st->vref); error_disable_reg: regulator_disable(st->reg); return ret; } static int ad799x_remove(struct i2c_client *client) { struct iio_dev *indio_dev = i2c_get_clientdata(client); struct ad799x_state *st = iio_priv(indio_dev); iio_device_unregister(indio_dev); iio_triggered_buffer_cleanup(indio_dev); regulator_disable(st->vref); regulator_disable(st->reg); kfree(st->rx_buf); return 0; } static const struct i2c_device_id ad799x_id[] = { { "ad7991", ad7991 }, { "ad7995", ad7995 }, { "ad7999", ad7999 }, { "ad7992", ad7992 }, { "ad7993", ad7993 }, { "ad7994", ad7994 }, { "ad7997", ad7997 }, { "ad7998", ad7998 }, {} }; MODULE_DEVICE_TABLE(i2c, ad799x_id); static struct i2c_driver ad799x_driver = { .driver = { .name = "ad799x", }, .probe = ad799x_probe, .remove = ad799x_remove, .id_table = ad799x_id, }; module_i2c_driver(ad799x_driver); MODULE_AUTHOR("Michael Hennerich "); MODULE_DESCRIPTION("Analog Devices AD799x ADC"); MODULE_LICENSE("GPL v2");