aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2019-02-24 23:13:44 +0100
committerKévin Redon <kredon@sysmocom.de>2019-02-27 13:46:46 +0000
commit5af7c8c36b4cc49e1ecf7acf13295a02c42bc7fd (patch)
tree7387b99b7ad9c84fa67fcf452a2da02b1c1d2571
parent1b9a5b81253e0fc147b1b8942704fecfe1c860d6 (diff)
ncn8025: Add support for reading SIMx_INT status
-rw-r--r--sysmoOCTSIM/ncn8025.c21
-rw-r--r--sysmoOCTSIM/ncn8025.h2
2 files changed, 22 insertions, 1 deletions
diff --git a/sysmoOCTSIM/ncn8025.c b/sysmoOCTSIM/ncn8025.c
index 5f9b03d..61509bc 100644
--- a/sysmoOCTSIM/ncn8025.c
+++ b/sysmoOCTSIM/ncn8025.c
@@ -11,6 +11,7 @@
#include <stdio.h>
#include <utils_assert.h>
#include <utils.h>
+#include "atmel_start_pins.h"
#include "octsim_i2c.h"
#include "ncn8025.h"
@@ -86,6 +87,20 @@ static const uint8_t slot2dir_reg(unsigned int slot)
return 0x03;
}
+static const uint8_t slot2int_pin(unsigned int slot)
+{
+ static const uint8_t slot2pin[8] = { SIM0_INT, SIM1_INT, SIM2_INT, SIM3_INT,
+ SIM4_INT, SIM5_INT, SIM6_INT, SIM7_INT };
+ ASSERT(slot < ARRAY_SIZE(slot2pin));
+ return slot2pin[slot];
+}
+
+bool ncn8025_interrupt_active(uint8_t slot)
+{
+ uint8_t pin = slot2int_pin(slot);
+ return !gpio_get_pin_level(pin);
+}
+
/*! Set a given NCN8025 as described in 'set'.
* \param[in] slot Slot number (0..7)
@@ -111,7 +126,9 @@ int ncn8025_get(uint8_t slot, struct ncn8025_settings *set)
rc = i2c_read_reg(adap, SX1503_ADDR, reg);
if (rc < 0)
return rc;
- return ncn8025_decode(rc, set);
+ rc = ncn8025_decode(rc, set);
+ set->interrupt = ncn8025_interrupt_active(slot);
+ return rc;
}
/*! default settings we use at start-up: powered off, in reset, slowest clock, 3V */
@@ -156,6 +173,8 @@ void ncn8025_dump(const struct ncn8025_settings *set)
printf(", RST");
if (set->cmdvcc)
printf(", VCC");
+ if (set->interrupt)
+ printf(", INT");
if (set->simpres)
printf(", SIMPRES");
if (set->led)
diff --git a/sysmoOCTSIM/ncn8025.h b/sysmoOCTSIM/ncn8025.h
index 79e8b60..89b7f86 100644
--- a/sysmoOCTSIM/ncn8025.h
+++ b/sysmoOCTSIM/ncn8025.h
@@ -19,11 +19,13 @@ struct ncn8025_settings {
bool cmdvcc; /* high: active */
bool simpres; /* high: active */
bool led; /* high: active */
+ bool interrupt; /* high: active */
enum ncn8025_sim_clkdiv clkdiv; /* raw 2bit value */
enum ncn8025_sim_voltage vsel; /* raw 2bit value */
};
int ncn8025_set(uint8_t slot, const struct ncn8025_settings *set);
int ncn8025_get(uint8_t slot, struct ncn8025_settings *set);
+bool ncn8025_interrupt_active(uint8_t slot);
int ncn8025_init(unsigned int slot);
void ncn8025_dump(const struct ncn8025_settings *set);