|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% r3 D4 g, _! F7 F#include <linux/init.h>
- ^) v6 D& J1 x: D6 R1 W: o#include <linux/module.h> s, W9 l8 j( V- w7 }3 y- f7 X& r
#include <linux/kernel.h>5 v. P4 e) }8 A5 ^1 J1 l, f% Z
#include <linux/types.h>+ g' I! ?% V8 u7 z
#include <linux/gpio.h>: q, c: ~' f1 @" j8 Z o( U
#include <linux/leds.h> f2 t) Y& Q% p2 b3 v( ?
#include <linux/platform_device.h>! \( X7 h9 B1 r
7 Q" s) H0 y( O5 T#include <asm/mach-types.h>6 ~; S5 y, y5 e) X. I# c0 ^5 q3 R5 i
#include <asm/mach/arch.h>
! P H# x* Z. b( s3 D#include <mach/da8xx.h>( {+ x/ v4 f; {0 `3 J7 T& z# M% V+ v
#include <mach/mux.h>
- ?. g2 A. G" @2 F8 c/ n
u9 n/ j( Z7 b: K$ d#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 Z. U$ M+ H* M; R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, {4 [; N4 [& ^3 Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). w9 w" M9 N- e3 e& K: w3 G6 ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# p) L' @$ z" L8 y6 V. c$ C* e% N [" A$ e L C
/* assign the tl som board LED-GPIOs*/& \3 [, k! k# c% x. n
static const short da850_evm_tl_user_led_pins[] = {, E4 s( H% d% g3 w/ P9 y7 G7 G
/* These pins are definition at <mach/mux.h> file */8 P7 O/ ]+ }* a/ n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) a P' ?5 H* H/ ]5 ~; s4 p -1
3 |7 @# N9 D5 u, @};
4 D! b$ A8 A( A/ @- D
' n. v/ R& Q( }4 h' q# jstatic struct gpio_led da850_evm_tl_leds[] = {
5 V( h# A" ?( w, `3 y' K {5 z4 ]9 x6 U( Y, l8 u& D
.active_low = 0,; t9 k" S0 c3 }& c. |4 ]
.gpio = DA850_USER_LED0,/ l/ R; I; I4 k
.name = "user_led0",
8 x; n6 K5 l3 a4 L6 y( P .default_trigger = "default-on",/ S, }3 o. Z( B5 Y4 m4 R6 g& J
},) {0 r( M3 i( I# V8 o
{
7 v/ {% g2 _% t5 F9 S$ t .active_low = 0,
) |& ]4 b: i" W/ A .gpio = DA850_USER_LED1,
. b( ?1 G' k* P .name = "user_led1",' T% Y7 s3 y7 _" U/ ?/ d# N
.default_trigger = "default-on",
) a: [% q' t( v4 X) @ },# C$ w7 @1 m5 U% t$ Y
{
' |- z, m+ P* I% d b1 H. @* t .active_low = 0,5 G- F: B* B) I' V6 M( {
.gpio = DA850_USER_LED2,
; m# h" O! w n! F; B. o( s( C .name = "user_led2",
, m! I7 I1 J* X: [$ D, _& L/ m .default_trigger = "default-on",
c# ]6 y; x8 T },$ r* w- ]( h: g& P0 Z
{
" c q% ]' I/ H .active_low = 0,0 j1 ^: ]/ R1 o8 t R& m
.gpio = DA850_USER_LED3,2 ^3 }3 A2 ~+ c
.name = "user_led3",) l$ ~ B+ P0 ?) a' p1 E0 j
.default_trigger = "default-on",
; O0 s! y4 G! L& P$ I N$ e) r/ N },
7 L$ L9 d) V" A1 @' w};( i2 j: `. _7 o( [! ?2 i5 D! W
/ k1 V; p* |* Q8 S4 m Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! k5 b& a2 z% w/ F6 x .leds = da850_evm_tl_leds,
5 O" p' N2 ?' p5 D. w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ H1 b d% m4 |# Z8 b! n};
7 K* C `4 J+ n- U$ A# h) ^+ R9 d0 l3 P1 U
static void led_dev_release(struct device *dev)8 C) o& [- V0 u5 X; ^" o) W
{
$ p3 I s) Y2 Y8 g};& F( J# b7 Q6 Y _/ H
% a5 ?% |$ ^: G) n) xstatic struct platform_device da850_evm_tl_leds_device = {$ `$ P% N5 \. a) ]* v! ^
.name = "leds-gpio",
4 f* V: m; o3 k% E& D .id = 1,8 Q; D$ h0 K; x+ ^& J% o' s
.dev = {# M$ D7 k, |4 h) V# L5 h
.platform_data = &da850_evm_tl_leds_pdata,: z7 ^' c. c$ e3 i
.release = led_dev_release,9 N7 j% ]3 y+ `# M* w! b
}& C) q4 A. k \( L+ k
};
# m' U3 [3 Z2 Y P( Y/ v5 v$ S- ~$ ]1 |
static int __init led_platform_init(void)
" @; ~7 |% U# Z) l" J) x{
- F, |3 X6 @( `, x8 Q% M int ret;( x4 E+ y/ P g9 Q7 y
#if 0
5 ]9 `; v; j9 } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 I% h! @! e% x% r7 F( a* p: ^
if (ret)
) C K# A" Z! c pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* ^$ p3 X1 ~( T7 k4 N8 S4 W, K% y+ Q
"%d\n", ret);
, o7 h1 e- L% ^. U3 ? b5 s#endif' y" V2 s/ s! A; o
ret = platform_device_register(&da850_evm_tl_leds_device);
$ X* `/ M, ~$ y9 A9 R' ?" d if (ret)) q# J" \1 E* Z- A
pr_warning("Could not register som GPIO expander LEDS");
$ F2 L# S7 C) _8 q else
: m5 c, Z2 W; d6 n8 D5 n$ W) W printk(KERN_INFO "LED register sucessful!\n");* t3 M, y$ @% n' y
; s5 @! u. z/ O
return ret;' e& r% d) m* m0 F
}" V3 M1 I y9 B
- N: _3 m+ z) X/ h& p/ t2 @9 W9 ^
static void __exit led_platform_exit(void)! F1 D8 d* s4 D( ~* k4 T' Z/ ^
{
/ t& H& o A6 B8 L5 g platform_device_unregister(&da850_evm_tl_leds_device);( R5 J; Q4 z0 q d2 `
; Y; Z4 S# I0 C, h$ M! W/ E printk(KERN_INFO "LED unregister!\n");
8 z6 K! X; e2 N3 L! M}+ N) f" C; N& p* X$ e
- Y# i" B7 \+ R2 q
module_init(led_platform_init);% E \0 g3 x. b4 g) c( r& O# s3 d
module_exit(led_platform_exit);" ?8 ~9 O" V) }! q4 {: U* n1 h
, m$ p" J/ k+ ^) A( \; PMODULE_DESCRIPTION("Led platform driver");7 X2 S' V! B+ ]2 f) x; E1 \
MODULE_AUTHOR("Tronlong");9 V3 O0 D+ y$ K- A" Y
MODULE_LICENSE("GPL");
& }- A4 C& {7 l X' Q7 }/ u4 g; a/ S& h0 _& J1 S! ?
|
|