|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 f' m6 E% P T# v% t% X# w6 O#include <linux/init.h>
0 A+ ]' I4 L# F6 x7 v9 s" w/ o#include <linux/module.h># w7 `9 c- X' P3 Z/ p! E1 |+ D) O7 C
#include <linux/kernel.h>9 B3 K& [& x( C$ N9 k0 [
#include <linux/types.h>5 n- p' }. u, A* Q( f7 h* [
#include <linux/gpio.h>8 Q' O) C0 y, m% i' g
#include <linux/leds.h>3 R' ^& ?1 M/ d- ~, M
#include <linux/platform_device.h>5 D [, ]: s& e. y x6 \
5 A* x" _% o. ^: j0 p
#include <asm/mach-types.h>
# _$ [4 D' A( ^7 p- ]9 I8 w#include <asm/mach/arch.h>. _- q( s7 I% b. y1 i, b$ B* U
#include <mach/da8xx.h>- F1 M8 O' Q/ a8 e4 D6 q
#include <mach/mux.h>
9 f% R/ R; v1 M% Z8 r: E2 a+ g: _1 X! ^# U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; k' t. P1 N; ]#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! s7 b8 q& Y# y/ Y8 }/ n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: h) d X; q- _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 n2 @4 e1 `7 w. R @# ^8 P- x3 F
1 Y0 [( h5 ~6 x7 W' F/* assign the tl som board LED-GPIOs*/
, |3 q! N2 {5 `0 jstatic const short da850_evm_tl_user_led_pins[] = {
( s& s2 G7 v: i1 _) \, o /* These pins are definition at <mach/mux.h> file */5 D, Z! [' |3 u9 J9 }# L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ |/ t' i" j: o1 W3 E: L. j -1
: y: \1 m9 K( J. t};
) } ~! [4 |2 Y! ^. f: v+ D* Q2 ?( d1 Y( ^# n$ z
static struct gpio_led da850_evm_tl_leds[] = {1 y3 \& o9 Z. ^, k: n2 E0 K' f
{
4 D7 J% j# \/ M+ g* ] .active_low = 0," s# B! K4 V. R! _
.gpio = DA850_USER_LED0, a& i4 k/ m( D, ?0 y
.name = "user_led0",5 I1 Q0 o7 m! o$ T
.default_trigger = "default-on",
+ {$ R) ?6 e5 b9 U \3 c5 W },
) e& @" M2 l1 F: ~+ m {
' G4 ]2 M' U- u9 J, Z) {5 e# E, ` .active_low = 0,; ]. K6 k$ `: N, a* e% P% V% W
.gpio = DA850_USER_LED1,# [; G% g1 L+ z& D/ s* \7 V
.name = "user_led1",9 y# E# w+ @0 S) J) Y
.default_trigger = "default-on",
" @* [* v5 z3 b! I+ o0 r1 F },# F7 e/ V$ {2 B1 }3 _' D
{
?) t$ N, R# |9 D .active_low = 0,
: B5 E- w' J9 C1 h .gpio = DA850_USER_LED2,4 V$ `5 P( ^3 H$ e, K
.name = "user_led2",$ f( m8 ~, d" x
.default_trigger = "default-on",
3 K R% J8 B2 M" t* Z },
6 D h' b' T3 h {
3 b! x- j: k( D! ?7 E* U% C P6 P .active_low = 0,+ u9 J6 Z: m1 t* N' I) W) q. C5 e7 H" ?
.gpio = DA850_USER_LED3,
, C& Z! z, L" U7 }' E; z$ d+ q .name = "user_led3",
O. I9 Y- [7 n .default_trigger = "default-on",
7 u, v$ R/ `$ V/ ~' ^9 X; b },) t- K. W6 U! _; E9 V5 m% O. j
};# L) c; u4 a3 Y; K+ H: ~0 W4 Z
& y3 J6 p& a* I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 {) c7 e3 `! M4 Q+ q: J+ s7 u
.leds = da850_evm_tl_leds,
& _' T- r' Z5 {( J .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: Z) `6 Z7 `( ^# p0 }! M};' m6 a7 W/ J% h, G T8 _# o1 ]
7 N8 b% e4 _. m
static void led_dev_release(struct device *dev)& h w( x1 x. O) B. E
{
$ S% |$ h5 W; B, v$ R};
" ~" K+ X% ^" ]4 A+ o! |/ c
W. C6 P: t. I" C: U* rstatic struct platform_device da850_evm_tl_leds_device = {
3 u: D/ @8 {/ u7 C3 ]$ h6 f .name = "leds-gpio",
0 ~6 Z2 _# l# ]* ~ .id = 1,5 }4 g; I' l) Q* ^9 G
.dev = {& \/ @ S* a% Q
.platform_data = &da850_evm_tl_leds_pdata,' f# O+ ^: |& i* K, i, n
.release = led_dev_release,5 @$ [7 q- Z4 o) {$ D% E8 ^9 X3 ?
}
6 w4 u) H& X/ j};
+ t D& y2 A9 X( u: `
( F1 _' g9 v' h. Z4 V# T4 @1 ]static int __init led_platform_init(void)9 p2 o& R9 o- ~
{
' k2 i; ~3 y' | int ret;" f& P+ M n3 l$ y8 }3 D
#if 0* I# _$ g% B' H( l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; O5 F- N4 K/ a; d if (ret)
( e! x& r8 i, v" ~ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( i& r. o) p7 ?9 ~
"%d\n", ret);
% @/ m, Y! S2 B! \' S" n) T5 m0 E& B& x#endif
N8 H7 q+ a; |( s' Y ret = platform_device_register(&da850_evm_tl_leds_device);7 z' O5 ~" Q9 O+ A
if (ret)3 y2 n$ b' E4 u: S; q
pr_warning("Could not register som GPIO expander LEDS");& g( G9 k; }* w; G# d, u: l
else
/ a8 T2 j! i) N/ D3 F printk(KERN_INFO "LED register sucessful!\n");( O! l9 m% @) h1 Y
2 Y2 v o( r O8 ~# ] v; g
return ret;
6 i5 X* T: F! J3 H4 J7 j$ b}' L/ b% p) @8 G+ w( x/ ]( H: [
% l, F- G& O' }) Y# jstatic void __exit led_platform_exit(void)7 l3 _( l9 i9 K- D9 w2 Q
{, _5 E" v1 `+ f# m! v. e
platform_device_unregister(&da850_evm_tl_leds_device);
9 {7 m2 ]! t% U5 T- p
/ e3 L; n' z* s* Y8 y2 p printk(KERN_INFO "LED unregister!\n");
4 T0 t$ K2 X s* h# N}
0 e5 y% @2 g; x5 K# |9 y4 s9 Y% j; T! y4 `
module_init(led_platform_init);
$ J4 c: J& Y2 P7 K9 j) Omodule_exit(led_platform_exit);! r6 k3 n8 d {# i3 r0 m
* `* l- V& ?7 D/ R
MODULE_DESCRIPTION("Led platform driver");5 M5 u9 o0 r& e. x
MODULE_AUTHOR("Tronlong");
, A) X2 H" N! sMODULE_LICENSE("GPL");
0 r" W" ^/ o" m# D/ M
0 x/ b6 c$ V) [, r- `' m8 Q |
|