|
求大神给下面的程序做注解,请稍详细些,谢谢。
& W3 S8 O: q1 l0 K#include <linux/init.h> X+ g; p/ ]0 d% `7 ?
#include <linux/module.h>. J Z4 T: ], a- k
#include <linux/kernel.h>
$ }0 o5 N* R7 h+ V$ e#include <linux/types.h>3 l9 z5 E. g% j& u4 {. Z' P0 P
#include <linux/gpio.h>
8 C( p# R( P2 @- W6 L2 ~#include <linux/leds.h>1 Z' c _) X( E% L0 G+ r
#include <linux/platform_device.h>0 A0 h0 B* }4 r2 i/ X7 o' ^7 |
- k: J# ~, n1 a
#include <asm/mach-types.h>8 n( x% s: V" t0 a) s+ i
#include <asm/mach/arch.h>5 M4 ]5 @4 y0 Q- l# ]* @1 f6 w
#include <mach/da8xx.h>
8 V/ L6 A1 i6 W1 ?#include <mach/mux.h>: n# M' M& T" h5 [
: v: b( m, p, d- [" B
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 O) A1 _+ M7 s* h8 l: g& _0 u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 a3 `9 L( W9 G8 S# V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 E1 b' l. H5 G# S9 p#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 s* E: d6 @& D2 T, I |! n( b/ ~) S
/* assign the tl som board LED-GPIOs*/
4 e' d( w# l) T$ M; vstatic const short da850_evm_tl_user_led_pins[] = {
. K' }. v1 |. a) @; z# x2 V7 f; P /* These pins are definition at <mach/mux.h> file */
$ x) J# s: z* R& Z8 E$ c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' e- {/ I. _ f7 [; ?
-1
( C4 Q# ^5 @5 r) ~. K5 |2 f};" y, n: q: O' f, D: n' V0 P+ o
& c' Y+ A# [1 m; I# M, Q
static struct gpio_led da850_evm_tl_leds[] = {7 k# P: ^# L- n1 [% M5 b
{
. W8 }8 M5 l5 s- `# D4 ? .active_low = 0,
! N F9 C+ n/ @5 K4 q% t .gpio = DA850_USER_LED0,' W" D4 J% r% h V
.name = "user_led0",- l, ?) C: B& q* P
.default_trigger = "default-on",
$ z) U" A9 Z3 ` },
4 O: n/ w' U1 {/ e, v) h {. T: n; u3 \% X* `
.active_low = 0,# F- ^& x: t7 b8 `4 e' p( w! S: q
.gpio = DA850_USER_LED1,1 n1 w; m: F/ Q$ ]2 G! C: z; M
.name = "user_led1"," T8 B$ a+ O' X4 ?
.default_trigger = "default-on",
1 e' g2 w$ V0 _+ s) v4 S },. _ O# J& [: |$ c/ C* s- a' ]
{
6 y2 x) ?0 ~# j, P. j .active_low = 0,
" X* d$ G! k2 P% a! N; ~& e .gpio = DA850_USER_LED2,$ \1 w! i2 G: O1 T( |
.name = "user_led2",
$ ^; z/ k) C# t4 B5 T8 S .default_trigger = "default-on",6 ^9 I" O0 e$ s7 b2 W+ K
}, U, @" y) p+ s* C z
{
# M) S; P& B2 s( {7 e7 P .active_low = 0, u& F' T+ u. {* R2 L
.gpio = DA850_USER_LED3,
! `% y& J. b; g1 n$ i) {2 ~ .name = "user_led3",9 B8 B- M# i7 S* g* k3 ^
.default_trigger = "default-on",
, a7 }# h2 u# r },
" q" E) n6 p5 Q7 V5 R) a};: Y3 T1 K8 X7 V5 B' o. I6 x6 I
4 T. V4 a! U- A ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 K6 d5 ~2 d9 D2 t
.leds = da850_evm_tl_leds,
, O6 x; a! {% h: q8 T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# a" i7 x& |1 J$ n
};3 p7 C9 _! M+ y" X8 ?. P* d% Y. t0 G
9 m5 N' F# v/ j: cstatic void led_dev_release(struct device *dev)
5 ~( ^3 m: @1 j1 T) K* w" }& d{; G1 R7 r9 U2 C+ U3 w
};
2 }% K8 ^; U e. ]8 b
2 c8 q! R- o. [+ w/ E* \static struct platform_device da850_evm_tl_leds_device = {& y, @ N& U% g% r' Y2 y3 t# E2 F
.name = "leds-gpio",( T. B; v$ B- r8 b/ B& z+ l3 s
.id = 1, [! S1 ~$ x$ z( U5 T9 B& \3 g! Y5 n
.dev = {+ N' S9 U3 X, w9 V* K" H' m
.platform_data = &da850_evm_tl_leds_pdata,/ ^3 ?: w; T1 ]1 u4 r
.release = led_dev_release,
0 Y, H. Y9 y) ?) M8 j# y; ` }6 z5 _: i: Y4 k- B. U7 @( Y9 ^
};
9 D. f) F) Y1 ]+ U" g8 {- t0 E. ]7 y9 o, o r8 Y( d/ p
static int __init led_platform_init(void)
0 e) C" v; r% U, ?; y{4 _% Q# E7 x8 U# {# E5 L% \
int ret;
; m- t% H# K/ D0 ^- H#if 0: s/ }3 K. }' J6 m
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( }4 F3 E! N; x6 E0 b' l3 C/ u if (ret)
0 n8 u0 ^6 k; ^' F" Y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! {- h; K% r& r0 b7 g
"%d\n", ret);
. x1 ^/ L% _7 V$ R( K; ^3 R8 c9 f#endif
0 e4 n z- ~2 a ret = platform_device_register(&da850_evm_tl_leds_device);
6 y$ k9 R) O! d4 p if (ret)
d" R0 B9 m0 N+ ?6 F5 R pr_warning("Could not register som GPIO expander LEDS");
! V8 x% m7 ^- q Y else
3 L- U1 i5 ^9 u8 B9 u printk(KERN_INFO "LED register sucessful!\n");6 l- o- H7 a+ i# z- i! ~- s# A
" t; g Q6 l' ~9 X7 v+ X, \ return ret;
9 y( n7 }' m9 |: D' p( {}# K1 i6 J4 I; g9 F1 F7 I7 F
9 J; y# g5 m3 ~) G% n. |( J
static void __exit led_platform_exit(void)) B3 q! i+ k/ L/ H
{
; Z& O5 G3 K9 T7 G) {5 u& _ platform_device_unregister(&da850_evm_tl_leds_device);- Z% n* i- J5 I# v
% r+ T9 o+ V/ Z0 ]6 h% W
printk(KERN_INFO "LED unregister!\n");
! d) @) G; E: ]6 l6 ~$ h1 @! X}' M6 `. D2 W0 u# i
# W. F7 f- c4 Q0 d4 ]/ w' w2 Ymodule_init(led_platform_init);
; Z$ V4 L3 t& U4 l3 ]0 q7 }9 I- Zmodule_exit(led_platform_exit);$ s$ b4 P. L- h
6 R3 m, z7 B3 XMODULE_DESCRIPTION("Led platform driver");4 U% }4 C% j$ e+ L
MODULE_AUTHOR("Tronlong");% @0 g9 `* D9 ^8 M6 D; h- u2 G1 S
MODULE_LICENSE("GPL");9 n4 `. m/ s: s$ M* u+ R3 O: d" N
3 ]. p; u7 q8 l" t u/ f8 F2 n
|
|