|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ }" ]) b3 i j$ P! I4 B% O% q
#include <linux/init.h>; n& {$ W9 R- i6 l, ]& Q3 A8 o
#include <linux/module.h>1 t9 B& m9 p, I% z M% b% `. }' `
#include <linux/kernel.h># W/ u# n+ R" U& V
#include <linux/types.h> m8 q) R' }8 i A" @
#include <linux/gpio.h>
/ T e @& q( K: r1 l& J. [#include <linux/leds.h>( x" |' a# K2 L/ b
#include <linux/platform_device.h>" A: {1 l. K* x
" n( y' G! ?7 q#include <asm/mach-types.h>. a* ^1 _3 h$ ?( W
#include <asm/mach/arch.h>
& e o/ P+ T$ [# c#include <mach/da8xx.h>
; }5 I: m* j# n* \0 I7 `9 c#include <mach/mux.h>, e [5 V# p, J, S2 Q0 e
; E5 Q) J, p7 R" z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 V: `6 F! X# e. A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ G' U( s3 j9 Z' ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); h7 m6 i/ c/ G
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' f; O# D- N. Q) b4 {. N. M
* i7 W* {) A3 G" D- u8 G/* assign the tl som board LED-GPIOs*/6 P2 A& S9 b3 s
static const short da850_evm_tl_user_led_pins[] = {
) b3 Q1 _/ m J/ J2 o } /* These pins are definition at <mach/mux.h> file */
+ [5 E: G& b, l; [: V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; w. f: z5 \5 K -1
; F7 ^8 I+ V7 Z5 [; y1 U};, s9 o# d2 M) l: p# F
9 z) O( [& [: qstatic struct gpio_led da850_evm_tl_leds[] = {# V4 R( `$ _! G, b
{
( |4 ^# R- P* q( e' |0 E/ C, n .active_low = 0,- C, i+ K% h" `& x: v
.gpio = DA850_USER_LED0," j) P7 r/ q C% i
.name = "user_led0",2 H Z. Z- F5 ]2 d5 f0 R
.default_trigger = "default-on",
% a+ m2 I: t0 k1 b8 M9 z- x },7 Z% U. d" }" X0 E" E
{8 S* m- V; g# |/ P+ v$ [
.active_low = 0,/ } k, B8 ^+ r8 P, k& k
.gpio = DA850_USER_LED1,' l+ X T' Z" g. C# r
.name = "user_led1",
, g3 b5 _; e/ e( Q3 A .default_trigger = "default-on",
3 |( [) g7 Z! f( ` },
% f5 g# K* Z0 Z/ l2 r& C* S {
& J4 S/ z! V# i. m8 M& `' I .active_low = 0,0 m) |/ @) {$ C4 a2 c" U( G1 W
.gpio = DA850_USER_LED2,
6 T Z- t" |: V% O. Y! H) C- @$ | .name = "user_led2",1 k- c2 ~& e) p; M4 S
.default_trigger = "default-on",
4 N3 _; w3 u+ D/ _. z7 ] }," K, \2 c. Y' X' O" | f' M
{: U5 l. w- W0 }
.active_low = 0,
* I, c' L4 R' w( z' Q' t8 i* c .gpio = DA850_USER_LED3," x0 B" K) j+ U# @5 K
.name = "user_led3",
+ k5 Z( X' {" }; @# C .default_trigger = "default-on",
& l* ?) k+ j+ i0 B7 r Z2 D },; X& G* W; k+ n% r$ S! H
};
% G8 T' S. w Q ]. H
/ Q8 d) V; K/ P+ k$ t7 Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ k6 |4 l* i: F$ _% z# s# V* V
.leds = da850_evm_tl_leds,7 c: N9 x: ~- x; d' R4 y$ Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ M; F/ b+ L2 I
};! W& Q8 R, O6 E0 N+ u3 g5 E
1 O0 ]8 j) S; G1 ]
static void led_dev_release(struct device *dev)3 {: g; P$ N6 I
{3 H/ P* p$ X* A/ ?
};
2 Y" n$ V% B& C# f) Y$ N5 `
4 @8 g/ [4 i5 k" k! M$ j! Gstatic struct platform_device da850_evm_tl_leds_device = {
& W) A! B1 T/ O8 T .name = "leds-gpio",
- ?% Z% B! ?+ u- u" n* ?5 I7 { .id = 1,3 n3 A6 c; y& A4 Y& u4 q
.dev = {
! @+ D+ b9 h" e! ?. z .platform_data = &da850_evm_tl_leds_pdata,
% J7 h5 b* I4 b; a .release = led_dev_release,+ b/ E! N# Y4 h( u) }
}
0 _* \% O( Q+ o- Y$ @};$ f h. N: X( z8 C k2 i" n
; ?/ B8 g( C* R ~' I7 {5 K vstatic int __init led_platform_init(void)
; C. A# S% l$ _+ X2 U! Z& u/ l+ [{/ m. }0 @+ `( Q( y, n* s6 i
int ret;" s/ R- M' R" f2 E
#if 0
" L' P9 _" c f- F, y# Y4 y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. E9 o6 Y" s% s
if (ret)
2 g; [3 ?/ \9 P, i* H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 a* v( G1 @/ v: p
"%d\n", ret);
4 s4 P' O6 w9 Z$ Q {#endif: x* Y6 e- j. j s: J
ret = platform_device_register(&da850_evm_tl_leds_device);/ D! U- D1 r* N" p- _
if (ret), p0 z( {4 L8 M# m
pr_warning("Could not register som GPIO expander LEDS");7 F& }* p/ f+ ?9 ]
else
; P% p2 U/ Y3 \" y printk(KERN_INFO "LED register sucessful!\n");
8 d {' b" F: `4 V6 H: H0 Q' x' D2 h
return ret;7 W+ h1 U6 K% g( f2 Y& U
}
: u( }' _0 u, d( Q0 H! I. x5 `9 A1 I
static void __exit led_platform_exit(void)$ j9 S: f. T5 w+ V5 y
{
% L( ^0 @3 ?" q W a6 j4 r platform_device_unregister(&da850_evm_tl_leds_device);
# L( E! v( X+ |. }) t% _
8 [" Q/ ?" h4 m/ ~ printk(KERN_INFO "LED unregister!\n");0 y% _2 q8 i" a0 K3 ] g+ [
}
! t) Z5 \4 H" F* j4 }; `1 O, x9 `2 I. m/ G+ h% [; u. l0 w1 P
module_init(led_platform_init);! d; V6 E0 g/ H: B/ |9 l. T, r
module_exit(led_platform_exit);: U4 {" B4 E5 Y
/ Y& F' z# ?, ~MODULE_DESCRIPTION("Led platform driver");
3 `( s" Z* O' L7 v! I0 s9 H4 h/ dMODULE_AUTHOR("Tronlong");2 W. M. P' m% H$ H
MODULE_LICENSE("GPL");. q- \8 a% g5 |; X; s
: c& P) P6 W8 }2 i% \9 Y( U* E
|
|