|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% b- }$ N2 [0 o6 ] |- Z
#include <linux/init.h>
, S! g0 ?) j. J0 g#include <linux/module.h>. H" ^2 Y1 L6 R5 o/ c; C
#include <linux/kernel.h>$ q$ F2 x K. b: k- N
#include <linux/types.h>
8 e. z# R# ~" d$ u3 _ J8 c3 _#include <linux/gpio.h>
4 T* s' ]0 G" M+ Z/ X! _" d$ Z#include <linux/leds.h>
) I" V2 D5 B/ r2 o0 H( d' _ N#include <linux/platform_device.h>, E) ~) B/ K: b
& H& Z: x7 z& v/ m1 g2 ~#include <asm/mach-types.h>9 \4 S) `1 W+ |7 F6 k8 I
#include <asm/mach/arch.h>6 r8 s9 x6 N( t$ t" E9 j
#include <mach/da8xx.h>
/ A* F. B3 b; H$ x" j% K C9 W#include <mach/mux.h>6 ?" @: Z7 B: t! M
s: `+ z+ G' e
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; V% [2 R- z2 l8 F, l1 Y+ n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! R* j7 N' _: \2 {" t
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" R6 k W- [: E. e# Z: B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ @1 B3 _+ L( S# E/ u# y1 y
% s) o2 Z. S( h" x: E9 L/* assign the tl som board LED-GPIOs*/( L- H1 ^$ |2 Y+ ^
static const short da850_evm_tl_user_led_pins[] = {
# R7 k7 g+ W. F5 k0 v /* These pins are definition at <mach/mux.h> file */
X: z! M/ Z! e) d8 S l+ t DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, ?, W8 B: o) N3 Q1 d -15 H+ n; ~2 h- t r
};
9 ~/ L/ ?2 g) I% b, p$ n- o) j1 u! T! D! [0 i; K, t5 |
static struct gpio_led da850_evm_tl_leds[] = {7 v* o* F3 }; q# k8 l( L, {7 v
{
) A8 g* L% n$ k; z6 J& Z .active_low = 0,3 J4 ?$ t/ t" w% N: l1 W1 l) k4 t
.gpio = DA850_USER_LED0,! x4 n7 T$ ]* T) v" w
.name = "user_led0",
" \; `1 e) O* {; K- Y: v .default_trigger = "default-on",
% Y5 J, f! j' k },
/ n6 l, {& E; @. G! P& }) R {- w% K8 m5 u1 O# }0 O0 Q: y8 \0 l. O
.active_low = 0,
# E4 `0 b0 f( q7 W& v8 a% S# O, d .gpio = DA850_USER_LED1,$ ~& l9 ?9 F$ X8 G2 e8 R
.name = "user_led1",
9 v* {9 D4 L/ {: c .default_trigger = "default-on",
, i5 L4 r* o w, ^ A# i8 B7 @5 y },; ?4 A/ U) M0 P/ r
{
7 u; ^% D/ ?1 O! d$ q .active_low = 0,
% _, b6 C& X* G! N2 R$ p/ A .gpio = DA850_USER_LED2,
( v9 T' G) N8 g3 j1 l .name = "user_led2",
3 @, b+ }! A. C/ }( n6 }" \ .default_trigger = "default-on",
( }) f3 r( q$ f" A },! j- N; G8 d Z; Z/ l' Z0 A
{
; W; @% k9 k" h" q; v# P .active_low = 0,4 y4 ^$ h$ G3 P$ W, }) v* x
.gpio = DA850_USER_LED3,# d* Y2 J0 S# X2 k; v4 D
.name = "user_led3",9 ~" f" N7 _* _/ u8 L
.default_trigger = "default-on",- g9 [7 U8 R7 U7 J5 w" |3 ^. _
},
( ~ l& s, T4 @/ ]8 V};
' U. G& ^& W. v0 e, c- I2 y3 D. G) q+ S" N' Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 F9 U- _+ Y( Y4 p7 I- _8 A5 T% `
.leds = da850_evm_tl_leds,
/ W/ ?- ^/ w- c. H .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 _' \' d6 A4 y: w b/ y" ~ A
};
5 b2 M% R7 a8 W# {3 M. [# T& u% A: }: C+ F: w
static void led_dev_release(struct device *dev)$ |; k4 |) T7 E$ K+ t% N
{8 m% f) a0 L0 _8 [. I; h
};2 l f- @3 d) Q0 k7 D
4 A4 i5 s( ]7 V0 h+ Y7 i1 D
static struct platform_device da850_evm_tl_leds_device = {4 D4 T+ v2 X) s1 t, R6 S% Z
.name = "leds-gpio",8 O( f) `$ v `2 m' c1 _# L1 Z# E
.id = 1,+ a0 x2 f, c2 u% ?: B
.dev = {
" l" \2 { f# s .platform_data = &da850_evm_tl_leds_pdata,- m( V+ w# _5 I2 M4 M$ y' F5 W A
.release = led_dev_release,6 i" E; a* m6 [, H* l
}; N y! T1 K" [8 U. L5 ?+ T+ n+ d
};
6 v6 S1 k+ i3 s: h1 C. e0 k: C$ w0 I* c d' H* C) l. U
static int __init led_platform_init(void)
7 t! T. d" k3 j{
4 F1 X9 u& r- U9 d) d int ret;
% o c, N2 v3 U7 \3 p1 ]- ]#if 02 g% I& `- C. B% l' T, g6 X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- l t; S/ Q7 o/ @, W9 n if (ret). M0 l2 w) P' G
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& C1 T9 l* Q1 d- o9 g
"%d\n", ret);- }, B1 J1 ?6 O2 y2 ~
#endif
9 E0 s( z% b6 q$ A2 O ret = platform_device_register(&da850_evm_tl_leds_device);
W1 ` f- g( y if (ret)
" P4 w; C+ a# O+ @6 e4 _8 S1 E pr_warning("Could not register som GPIO expander LEDS");, _, p8 @0 [* A( p$ V; |9 T1 x
else
' D5 _3 c6 s/ H/ Q) Y' A printk(KERN_INFO "LED register sucessful!\n");, B, p3 Q- H( D {2 N
+ o% \. c: @, L4 r
return ret;1 v2 b. X* u3 t/ t
}( R4 O& C- M: F# ^$ [+ T
) o. O9 z0 i* Xstatic void __exit led_platform_exit(void)
3 ~) {6 l# q$ A/ E' t{
7 m! j' Z+ q3 J( r* m. }3 M( \ platform_device_unregister(&da850_evm_tl_leds_device);2 B+ Y% {0 r3 a
& [% C3 Q" f+ ^& }+ G Q printk(KERN_INFO "LED unregister!\n");, u$ D7 x. ] J4 w) x
}6 C/ {, K, K" U4 w0 l9 |
3 }0 S) a* E8 L8 H# \
module_init(led_platform_init);
4 L7 M) O/ F! ~module_exit(led_platform_exit);
, r$ R; V# z5 r
/ _, g7 \1 @6 j' k% [MODULE_DESCRIPTION("Led platform driver"); c C8 o- h+ M6 j ^
MODULE_AUTHOR("Tronlong");* p$ ]3 |( ]+ q% |: w
MODULE_LICENSE("GPL");5 T' Z3 P! {. h* t. [. n$ I& e
; v) s9 A P' A) r% n. B1 a1 q
|
|