Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1322537 > unrolled thread
| Started by | Sebastian Reichel <sre@kernel.org> |
|---|---|
| First post | 2016-01-31 02:30 +0100 |
| Last post | 2016-01-31 19:40 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 3/5] HSI: ssi-protocol: export modem info via sysfs Sebastian Reichel <sre@kernel.org> - 2016-01-31 02:30 +0100
Re: [PATCH 3/5] HSI: ssi-protocol: export modem info via sysfs Pavel Machek <pavel@ucw.cz> - 2016-01-31 18:40 +0100
Re: [PATCH 3/5] HSI: ssi-protocol: export modem info via sysfs Sebastian Reichel <sre@kernel.org> - 2016-01-31 19:40 +0100
| From | Sebastian Reichel <sre@kernel.org> |
|---|---|
| Date | 2016-01-31 02:30 +0100 |
| Subject | [PATCH 3/5] HSI: ssi-protocol: export modem info via sysfs |
| Message-ID | <qWOZY-44I-5@gated-at.bofh.it> |
Currently userspace knows about the rapuyama version by
checking, which gpios have been exported. This does no
longer work with kernel based power management, so export
a sysfs file, which provides the rapuyama generation. Also
export a link to the nokia-modem, so that userspace can
easily check if kernel based PM is used.
Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
drivers/hsi/clients/nokia-modem.c | 10 ++++------
drivers/hsi/clients/ssi_protocol.c | 33 ++++++++++++++++++++++++++++++++-
include/linux/hsi/ssi_protocol.h | 11 +++++++++++
3 files changed, 47 insertions(+), 7 deletions(-)
diff --git a/drivers/hsi/clients/nokia-modem.c b/drivers/hsi/clients/nokia-modem.c
index 6485f4c61092..1b4a250cf113 100644
--- a/drivers/hsi/clients/nokia-modem.c
+++ b/drivers/hsi/clients/nokia-modem.c
@@ -35,11 +35,6 @@ module_param(pm, int, 0400);
MODULE_PARM_DESC(pm,
"Enable power management (0=disabled, 1=userland based [default], 2=kernel based)");
-enum nokia_modem_type {
- RAPUYAMA_V1,
- RAPUYAMA_V2,
-};
-
struct nokia_modem_device {
struct tasklet_struct nokia_modem_rst_ind_tasklet;
int nokia_modem_rst_ind_irq;
@@ -285,6 +280,7 @@ static int nokia_modem_probe(struct device *dev)
struct hsi_port *port = hsi_get_port(cl);
int irq, pflags, err;
struct hsi_board_info ssip;
+ struct ssi_protocol_platform_data ssip_pdata;
struct hsi_board_info cmtspeech;
np = dev->of_node;
@@ -340,7 +336,9 @@ static int nokia_modem_probe(struct device *dev)
ssip.name = "ssi-protocol";
ssip.tx_cfg = cl->tx_cfg;
ssip.rx_cfg = cl->rx_cfg;
- ssip.platform_data = NULL;
+ ssip_pdata.type = modem->type;
+ ssip_pdata.nokia_modem_dev = dev;
+ ssip.platform_data = &ssip_pdata;
ssip.archdata = NULL;
modem->ssi_protocol = hsi_new_client(port, &ssip);
diff --git a/drivers/hsi/clients/ssi_protocol.c b/drivers/hsi/clients/ssi_protocol.c
index cee33cab889e..3fb5b98b2c63 100644
--- a/drivers/hsi/clients/ssi_protocol.c
+++ b/drivers/hsi/clients/ssi_protocol.c
@@ -154,6 +154,7 @@ struct ssi_protocol {
int channel_id_cmd;
int channel_id_data;
struct blocking_notifier_head modem_state_notifier;
+ enum nokia_modem_type modem_type;
};
/* List of ssi protocol instances */
@@ -1080,10 +1081,20 @@ static void ssip_pn_setup(struct net_device *dev)
dev->header_ops = &phonet_header_ops;
}
+static ssize_t show_rapuyama_version(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct hsi_client *cl = to_hsi_client(dev);
+ struct ssi_protocol *ssi = hsi_client_drvdata(cl);
+
+ return sprintf(buf, "%d", ssi->modem_type);
+}
+static DEVICE_ATTR(rapuyama_version, S_IRUGO, show_rapuyama_version, 0);
+
static int ssi_protocol_probe(struct device *dev)
{
static const char ifname[] = "phonet%d";
struct hsi_client *cl = to_hsi_client(dev);
+ struct ssi_protocol_platform_data *pdata = dev_get_platdata(dev);
struct ssi_protocol *ssi;
int err;
@@ -1093,6 +1104,8 @@ static int ssi_protocol_probe(struct device *dev)
return -ENOMEM;
}
+ ssi->modem_type = pdata->type;
+
spin_lock_init(&ssi->lock);
init_timer_deferrable(&ssi->rx_wd);
init_timer_deferrable(&ssi->tx_wd);
@@ -1137,12 +1150,24 @@ static int ssi_protocol_probe(struct device *dev)
goto out1;
}
+ err = device_create_file(dev, &dev_attr_rapuyama_version);
+ if (err < 0) {
+ dev_err(dev, "Could not create sysfs file for rapuyama version");
+ goto out2;
+ }
+
+ err = sysfs_create_link(&dev->kobj, &pdata->nokia_modem_dev->kobj, "nokia-modem");
+ if (err < 0) {
+ dev_err(dev, "Could not create sysfs symlink to nokia-modem");
+ goto out3;
+ }
+
SET_NETDEV_DEV(ssi->netdev, dev);
netif_carrier_off(ssi->netdev);
err = register_netdev(ssi->netdev);
if (err < 0) {
dev_err(dev, "Register netdev failed (%d)\n", err);
- goto out2;
+ goto out4;
}
list_add(&ssi->link, &ssip_list);
@@ -1151,6 +1176,10 @@ static int ssi_protocol_probe(struct device *dev)
ssi->channel_id_cmd, ssi->channel_id_data);
return 0;
+out4:
+ sysfs_remove_link(&dev->kobj, "nokia-modem");
+out3:
+ device_remove_file(dev, &dev_attr_rapuyama_version);
out2:
free_netdev(ssi->netdev);
out1:
@@ -1167,6 +1196,8 @@ static int ssi_protocol_remove(struct device *dev)
struct ssi_protocol *ssi = hsi_client_drvdata(cl);
list_del(&ssi->link);
+ sysfs_remove_link(&dev->kobj, "nokia-modem");
+ device_remove_file(dev, &dev_attr_rapuyama_version);
unregister_netdev(ssi->netdev);
ssip_free_cmds(ssi);
hsi_client_set_drvdata(cl, NULL);
diff --git a/include/linux/hsi/ssi_protocol.h b/include/linux/hsi/ssi_protocol.h
index 6b742e9368a7..ba069812341b 100644
--- a/include/linux/hsi/ssi_protocol.h
+++ b/include/linux/hsi/ssi_protocol.h
@@ -33,6 +33,17 @@ enum nokia_modem_state {
STATE_OFF,
};
+enum nokia_modem_type {
+ UNKNOWN = 0,
+ RAPUYAMA_V1,
+ RAPUYAMA_V2,
+};
+
+struct ssi_protocol_platform_data {
+ enum nokia_modem_type type;
+ struct device *nokia_modem_dev;
+};
+
static inline void ssip_slave_put_master(struct hsi_client *master)
{
}
--
2.7.0.rc3
[toc] | [next] | [standalone]
| From | Pavel Machek <pavel@ucw.cz> |
|---|---|
| Date | 2016-01-31 18:40 +0100 |
| Message-ID | <qX48G-6C6-17@gated-at.bofh.it> |
| In reply to | #1322537 |
On Sun 2016-01-31 02:19:45, Sebastian Reichel wrote: > Currently userspace knows about the rapuyama version by > checking, which gpios have been exported. This does no > longer work with kernel based power management, so export > a sysfs file, which provides the rapuyama generation. Also Umm. So patches 1-2 make it impossible for existing userspace to detect modem version? Even if we re-add the capability with this patch, that makes it bad idea, no? Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[toc] | [prev] | [next] | [standalone]
| From | Sebastian Reichel <sre@kernel.org> |
|---|---|
| Date | 2016-01-31 19:40 +0100 |
| Message-ID | <qX54K-7kU-5@gated-at.bofh.it> |
| In reply to | #1322690 |
[Multipart message — attachments visible in raw view] — view raw
Hi Pavel, On Sun, Jan 31, 2016 at 06:36:05PM +0100, Pavel Machek wrote: > On Sun 2016-01-31 02:19:45, Sebastian Reichel wrote: > > Currently userspace knows about the rapuyama version by > > checking, which gpios have been exported. This does no > > longer work with kernel based power management, so export > > a sysfs file, which provides the rapuyama generation. Also > > Umm. So patches 1-2 make it impossible for existing userspace to > detect modem version? > > Even if we re-add the capability with this patch, that makes it bad > idea, no? Thanks for having a look at the patches :) Looks like my commit messages are not verbose enough to show the whole thing. Let me try a more verbose explanation: The N900 and the N950 have more or less the same modem, but with different GPIOs. That basically means, that the powerup/down sequence works differently. OFono has code for supporting power management of both modems by detecting, that some gpios have not been exported. (So if, for some reason, you have not exported some of the GPIOs it will also think, that you have an N950 modem) For kernel based PM there won't be any GPIOs exported, so OFono cannot derive modem generation information from them. OTOH it no longer needs to, since the kernel will take care of the difference between the power up/down sequence. OFono only uses the derived modem generation information for the different power sequence. Unfortunately there is another difference between the N900 and N950 modem, that is not yet covered by OFono at all: The N950 has a broken CBS interface. So the current OFono code base is broken for the N950, even though it can power it up. The broken N950 CBS interface is currently not handled by either ofono, fso-gsmd or sscd. Thus using an explicit new interface is not a problem IMHO. Anyways, after this patchset you have the following methods for using the modem: 1. The existing way using pm=1, which is still the default for now. 2. The existing way using pm=1 + rapuyama_version to check if all GPIOs are there. 3. The new way using pm=2. You can use rapuyama_version for avoiding the CBS interface on N950. I don't think we can easily remove pm=1 support, since it will be needed by existing userspace software. I do think though, that we can change the default from pm=1 to pm=2 when support for the new interface has been integrated into userspace software for some time (e.g. 1 year after it has been merged). -- Sebastian
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web