Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
43cc32a2
Commit
43cc32a2
authored
Sep 07, 2014
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
greybus: first cut at parsing svc messages sent to the AP
parent
68f1fc4d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
151 additions
and
2 deletions
+151
-2
drivers/staging/greybus/ap.c
drivers/staging/greybus/ap.c
+6
-0
drivers/staging/greybus/es1-ap-usb.c
drivers/staging/greybus/es1-ap-usb.c
+145
-2
No files found.
drivers/staging/greybus/ap.c
View file @
43cc32a2
...
...
@@ -42,6 +42,12 @@ static struct svc_msg *convert_ap_message(struct ap_msg *ap_msg)
// for now, just cast the pointer and run away...
svc_msg
=
(
struct
svc_msg
*
)
ap_msg
->
data
;
// FIXME - put in correct version numbers
if
((
svc_msg
->
header
.
version_major
!=
0x00
)
&&
(
svc_msg
->
header
.
version_minor
!=
0x00
))
return
NULL
;
return
svc_msg
;
}
...
...
drivers/staging/greybus/es1-ap-usb.c
View file @
43cc32a2
...
...
@@ -11,6 +11,7 @@
#include <linux/errno.h>
#include <linux/usb.h>
#include "greybus.h"
#include "svc_msg.h"
static
const
struct
usb_device_id
id_table
[]
=
{
{
USB_DEVICE
(
0xffff
,
0x0001
)
},
// FIXME
...
...
@@ -81,6 +82,124 @@ static void free_gbuf(struct gbuf *gbuf)
kfree
(
buffer
);
}
static
struct
svc_msg
*
svc_msg_alloc
(
enum
svc_function_type
type
)
{
struct
svc_msg
*
svc_msg
;
svc_msg
=
kzalloc
((
sizeof
*
svc_msg
),
GFP_KERNEL
);
if
(
!
svc_msg
)
return
NULL
;
// FIXME - verify we are only sending message types we should be
svc_msg
->
header
.
type
=
type
;
return
svc_msg
;
}
static
void
svc_msg_free
(
struct
svc_msg
*
svc_msg
)
{
kfree
(
svc_msg
);
}
static
int
svc_msg_send
(
struct
svc_msg
*
svc_msg
)
{
// FIXME - Do something with this message!
svc_msg_free
(
svc_msg
);
return
0
;
}
static
void
svc_handshake
(
struct
svc_function_handshake
*
handshake
,
struct
es1_ap_dev
*
es1
)
{
struct
svc_msg
*
svc_msg
;
/* A new SVC communication channel, let's verify it was for us */
if
(
handshake
->
handshake_type
!=
SVC_HANDSHAKE_SVC_HELLO
)
{
/* we don't know what to do with this, log it and return */
dev_dbg
(
&
es1
->
usb_intf
->
dev
,
"received invalid handshake type %d
\n
"
,
handshake
->
handshake_type
);
return
;
}
/* Send back a AP_HELLO message */
svc_msg
=
svc_msg_alloc
(
SVC_FUNCTION_HANDSHAKE
);
if
(
!
svc_msg
)
return
;
svc_msg
->
handshake
.
handshake_type
=
SVC_HANDSHAKE_AP_HELLO
;
svc_msg_send
(
svc_msg
);
}
static
void
svc_management
(
struct
svc_function_unipro_management
*
management
,
struct
es1_ap_dev
*
es1
)
{
/* What? An AP should not get this message */
dev_err
(
&
es1
->
usb_intf
->
dev
,
"Got an svc management message???
\n
"
);
}
static
void
svc_hotplug
(
struct
svc_function_hotplug
*
hotplug
,
struct
es1_ap_dev
*
es1
)
{
u8
module_id
=
hotplug
->
module_id
;
switch
(
hotplug
->
hotplug_event
)
{
case
SVC_HOTPLUG_EVENT
:
dev_dbg
(
&
es1
->
usb_intf
->
dev
,
"module id %d added
\n
"
,
module_id
);
// FIXME - add the module to the system
break
;
case
SVC_HOTUNPLUG_EVENT
:
dev_dbg
(
&
es1
->
usb_intf
->
dev
,
"module id %d removed
\n
"
,
module_id
);
// FIXME - remove the module from the system
break
;
default:
dev_err
(
&
es1
->
usb_intf
->
dev
,
"received invalid hotplug message type %d
\n
"
,
hotplug
->
hotplug_event
);
break
;
}
}
static
void
svc_ddb
(
struct
svc_function_ddb
*
ddb
,
struct
es1_ap_dev
*
es1
)
{
/* What? An AP should not get this message */
dev_err
(
&
es1
->
usb_intf
->
dev
,
"Got an svc DDB message???
\n
"
);
}
static
void
svc_power
(
struct
svc_function_power
*
power
,
struct
es1_ap_dev
*
es1
)
{
u8
module_id
=
power
->
module_id
;
if
(
power
->
power_type
!=
SVC_POWER_BATTERY_STATUS
)
{
dev_err
(
&
es1
->
usb_intf
->
dev
,
"received invalid power type %d
\n
"
,
power
->
power_type
);
return
;
}
dev_dbg
(
&
es1
->
usb_intf
->
dev
,
"power status for module id %d is %d
\n
"
,
module_id
,
power
->
status
.
status
);
// FIXME - do something with the power information, like update our
// battery information...
}
static
void
svc_epm
(
struct
svc_function_epm
*
epm
,
struct
es1_ap_dev
*
es1
)
{
/* What? An AP should not get this message */
dev_err
(
&
es1
->
usb_intf
->
dev
,
"Got an EPM message???
\n
"
);
}
static
void
svc_suspend
(
struct
svc_function_suspend
*
suspend
,
struct
es1_ap_dev
*
es1
)
{
/* What? An AP should not get this message */
dev_err
(
&
es1
->
usb_intf
->
dev
,
"Got an suspend message???
\n
"
);
}
/* Main message loop for ap messages */
/* Odds are, most of this logic can move to core.c someday, but as we only have
...
...
@@ -90,8 +209,32 @@ static void ap_msg(struct svc_msg *svc_msg, struct greybus_host_device *hd)
struct
es1_ap_dev
*
es1
=
hd_to_es1
(
hd
);
/* Look at the message to figure out what to do with it */
switch
(
svc_msg
->
header
.
type
)
{
case
SVC_FUNCTION_HANDSHAKE
:
svc_handshake
(
&
svc_msg
->
handshake
,
es1
);
break
;
case
SVC_FUNCTION_UNIPRO_NETWORK_MANAGEMENT
:
svc_management
(
&
svc_msg
->
management
,
es1
);
break
;
case
SVC_FUNCTION_HOTPLUG
:
svc_hotplug
(
&
svc_msg
->
hotplug
,
es1
);
break
;
case
SVC_FUNCTION_DDB
:
svc_ddb
(
&
svc_msg
->
ddb
,
es1
);
break
;
case
SVC_FUNCTION_POWER
:
svc_power
(
&
svc_msg
->
power
,
es1
);
break
;
case
SVC_FUNCTION_EPM
:
svc_epm
(
&
svc_msg
->
epm
,
es1
);
break
;
case
SVC_FUNCTION_SUSPEND
:
svc_suspend
(
&
svc_msg
->
suspend
,
es1
);
break
;
default:
dev_err
(
&
es1
->
usb_intf
->
dev
,
"received invalid SVC message type %d
\n
"
,
svc_msg
->
header
.
type
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment